Interface MetaParam.Lookup
-
- All Known Subinterfaces:
EntryView.ReadEntryView<K,V>
,EntryView.ReadWriteEntryView<K,V>
,EntryViews.AccessLoggingReadWriteView<K,V>
- All Known Implementing Classes:
MetaParamsInternalMetadata
public static interface MetaParam.Lookup
Provides metadata parameter lookup capabilities usingClass
as lookup key.When the
MetaParam
type is generic, e.g.MetaParam.MetaEntryVersion
, passing the correctClass
information so that the return offindMetaParam(java.lang.Class<T>)
is of the expected type can be a bit tricky.MetaEntryVersion#type()
offers an easy way to retrieve the expectedMetaParam
type fromfindMetaParam(java.lang.Class<T>)
at the expense of some type safety:
In the future, the API might be adjusted to provide additional lookup methods where this situation is improved. Also, if theClass<MetaEntryVersion<Long>> type = MetaEntryVersion.type(); Optional<MetaEntryVersion<Long>> metaVersion = metaParamLookup.findMetaParam(type);
MetaParam
type is not generic, e.g.MetaParam.MetaLifespan
, the problem is avoided altogether:Optional<MetaLifespan<Long>> metaLifespan = metaParamLookup.findMetaParam(MetaLifespan.class);
A user that queries meta parameters can never assume that the meta parameter will always exist because there are scenarios, such as when compatibility mode is enabled, when meta parameters that are assumed to be present are not due to the API multiplexing that occurs. For example, when compatibility mode is enabled, the REST server can't assume that MIME metadata will be present since data might have been stored with embedded or remote (Hot Rod) API.
- Since:
- 8.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <T extends MetaParam>
Optional<T>findMetaParam(Class<T> type)
-
-
-
Method Detail
-
findMetaParam
<T extends MetaParam> Optional<T> findMetaParam(Class<T> type)
Returns a non-emptyOptional
instance containing a metadata parameter instance that can be assigned to the typeClass
passed in, or an emptyOptional
if no metadata can be assigned to that type.- Type Parameters:
T
- metadata parameter type
-
-