public static interface MetaParam.Lookup
Class as
lookup key.
When the MetaParam type is generic, e.g. MetaParam.MetaEntryVersion,
passing the correct Class information so that the return of
findMetaParam(java.lang.Class<T>) is of the expected type can be a bit tricky.
MetaEntryVersion#type() offers an easy way to retrieve the
expected MetaParam type from findMetaParam(java.lang.Class<T>) at the
expense of some type safety:
Class<MetaEntryVersion<Long>> type = MetaEntryVersion.type();
Optional<MetaEntryVersion<Long>> metaVersion =
metaParamLookup.findMetaParam(type);
In the future, the API might be adjusted to provide additional lookup
methods where this situation is improved. Also, if the 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 some of them depends on the cache usage.
| Modifier and Type | Method and Description |
|---|---|
<T extends MetaParam> |
findMetaParam(java.lang.Class<T> type)
Returns a non-empty
Optional instance containing a metadata
parameter instance that can be assigned to the type Class
passed in, or an empty Optional if no metadata can be assigned
to that type. |
<T extends MetaParam> java.util.Optional<T> findMetaParam(java.lang.Class<T> type)
Optional instance containing a metadata
parameter instance that can be assigned to the type Class
passed in, or an empty Optional if no metadata can be assigned
to that type.T - metadata parameter type