Package org.cache2k.config
Class CacheTypeCapture<T>
- java.lang.Object
-
- org.cache2k.config.CacheTypeCapture<T>
-
- All Implemented Interfaces:
CacheType<T>
public class CacheTypeCapture<T> extends Object implements CacheType<T>
Helper class to capture generic types into a type descriptor. This is used to provide the cache with detailed type information of the key and value objects. Example usage withCache2kBuilder:
This constructs a cache with the known typeCacheBuilder.newCache().valueType(new CacheType<List<String>(){}).build()List<String>for its value.- Author:
- Jens Wilke
- See Also:
- Google Guava CacheType explaination
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCacheTypeCapture.OfArrayCacheType representing an array.static classCacheTypeCapture.OfClass<T>CacheType representing a class.static classCacheTypeCapture.OfGeneric<T>CacheType representing a generic type.
-
Field Summary
-
Fields inherited from interface org.cache2k.config.CacheType
DESCRIPTOR_TO_STRING_PREFIX
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedCacheTypeCapture()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)@Nullable CacheType<?>getComponentType()The component type in case of an array@Nullable Class<T>getType()Class type if not an array.@Nullable CacheType<?>[]getTypeArguments()Known type arguments, if the type is a parametrized type.StringgetTypeName()Java language compatible type nameinthashCode()booleanhasTypeArguments()The type has generic type parameters and the concrete types are known.booleanisArray()This type is an array.StringtoString()
-
-
-
Method Detail
-
getComponentType
@Nullable public @Nullable CacheType<?> getComponentType()
Description copied from interface:CacheTypeThe component type in case of an array- Specified by:
getComponentTypein interfaceCacheType<T>
-
getType
@Nullable public @Nullable Class<T> getType()
Description copied from interface:CacheTypeClass type if not an array.
-
getTypeArguments
@Nullable public @Nullable CacheType<?>[] getTypeArguments()
Description copied from interface:CacheTypeKnown type arguments, if the type is a parametrized type.- Specified by:
getTypeArgumentsin interfaceCacheType<T>
-
getTypeName
public String getTypeName()
Description copied from interface:CacheTypeJava language compatible type name- Specified by:
getTypeNamein interfaceCacheType<T>
-
hasTypeArguments
public boolean hasTypeArguments()
Description copied from interface:CacheTypeThe type has generic type parameters and the concrete types are known.CacheType.getTypeArguments()returns the the arguments.- Specified by:
hasTypeArgumentsin interfaceCacheType<T>
-
isArray
public boolean isArray()
Description copied from interface:CacheTypeThis type is an array. To analyze a multi dimensional array descend to the component, for examplegetComponentType().isArray().- Specified by:
isArrayin interfaceCacheType<T>- See Also:
CacheType.getComponentType()
-
-