Package io.lettuce.core.dynamic.support
Class ClassTypeInformation<S>
- java.lang.Object
-
- io.lettuce.core.dynamic.support.ClassTypeInformation<S>
-
- All Implemented Interfaces:
TypeInformation<S>
public class ClassTypeInformation<S> extends Object
TypeInformation
for a plainClass
.
-
-
Field Summary
Fields Modifier and Type Field Description static ClassTypeInformation<Collection>
COLLECTION
static ClassTypeInformation<List>
LIST
static ClassTypeInformation<Map>
MAP
static ClassTypeInformation<Object>
OBJECT
static ClassTypeInformation<Set>
SET
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected TypeInformation<?>
createInfo(Type fieldType)
CreatesTypeInformation
for the givenType
.protected TypeInformation<?>
doGetComponentType()
protected TypeInformation<?>
doGetMapValueType()
boolean
equals(Object obj)
static <S> ClassTypeInformation<S>
from(Class<S> type)
Simple factory method to easily create new instances ofClassTypeInformation
.static <S> TypeInformation<S>
fromMethodParameter(Method method, int index)
Creates aTypeInformation
from the given method's parameter type.static <S> TypeInformation<S>
fromReturnTypeOf(Method method)
Creates aTypeInformation
from the given method's return type.TypeInformation<?>
getActualType()
Transparently returns theMap
value type if the type is aMap
, returns the component type if the typeTypeInformation.isCollectionLike()
or the simple type if none of this applies.TypeInformation<?>
getComponentType()
Returns the component type forCollection
s or the key type forMap
s.Type
getGenericType()
TypeInformation<?>
getMapValueType()
Will return the type of the value in case the underlying type is aMap
.List<TypeInformation<?>>
getParameterTypes(Constructor<?> constructor)
Returns theTypeInformation
s for the parameters of the givenConstructor
.List<TypeInformation<?>>
getParameterTypes(Method method)
Returns theTypeInformation
s for the parameters of the givenMethod
.ClassTypeInformation<?>
getRawTypeInformation()
Returns aClassTypeInformation
to represent theTypeInformation
of the raw type of the current instance.TypeInformation<?>
getReturnType(Method method)
Returns aTypeInformation
for the return type of the givenMethod
.TypeInformation<?>
getSuperTypeInformation(Class<?> superType)
Returns theTypeInformation
for the given raw super type.Class<S>
getType()
Returns the type of the property.TypeInformation<?>
getTypeArgument(Class<?> bound, int index)
List<TypeInformation<?>>
getTypeArguments()
Returns theTypeInformation
for the type arguments of the currentTypeInformation
.Map<TypeVariable<?>,Type>
getTypeVariableMap()
Returns the type variable map.int
hashCode()
boolean
isAssignableFrom(TypeInformation<?> target)
Returns if the currentTypeInformation
can be safely assigned to the given one.boolean
isCollectionLike()
Returns whether the type can be considered a collection, which means it's a container of elements, e.g.boolean
isMap()
Returns whether the property is aMap
.protected Class<S>
resolveClass(Type type)
Resolves the given type into a plainClass
.protected Type
resolveType(Type type)
Resolves the given type into aType
.String
toString()
-
-
-
Field Detail
-
COLLECTION
public static final ClassTypeInformation<Collection> COLLECTION
-
LIST
public static final ClassTypeInformation<List> LIST
-
SET
public static final ClassTypeInformation<Set> SET
-
MAP
public static final ClassTypeInformation<Map> MAP
-
OBJECT
public static final ClassTypeInformation<Object> OBJECT
-
-
Method Detail
-
from
public static <S> ClassTypeInformation<S> from(Class<S> type)
Simple factory method to easily create new instances ofClassTypeInformation
.- Type Parameters:
S
-- Parameters:
type
- must not benull
.- Returns:
-
fromReturnTypeOf
public static <S> TypeInformation<S> fromReturnTypeOf(Method method)
Creates aTypeInformation
from the given method's return type.- Parameters:
method
- must not benull
.- Returns:
-
fromMethodParameter
public static <S> TypeInformation<S> fromMethodParameter(Method method, int index)
Creates aTypeInformation
from the given method's parameter type.- Parameters:
method
- must not benull
.- Returns:
-
getType
public Class<S> getType()
Description copied from interface:TypeInformation
Returns the type of the property. Will resolve generics and the generic context of- Specified by:
getType
in interfaceTypeInformation<S>
- Returns:
-
getRawTypeInformation
public ClassTypeInformation<?> getRawTypeInformation()
Description copied from interface:TypeInformation
Returns aClassTypeInformation
to represent theTypeInformation
of the raw type of the current instance.- Specified by:
getRawTypeInformation
in interfaceTypeInformation<S>
- Returns:
-
isAssignableFrom
public boolean isAssignableFrom(TypeInformation<?> target)
Description copied from interface:TypeInformation
Returns if the currentTypeInformation
can be safely assigned to the given one. Mimics semantics ofClass.isAssignableFrom(Class)
but takes generics into account. Thus it will allow to detect that aList<Long>
is assignable toList<? extends Number>
.- Specified by:
isAssignableFrom
in interfaceTypeInformation<S>
- Returns:
-
getTypeVariableMap
public Map<TypeVariable<?>,Type> getTypeVariableMap()
Returns the type variable map.- Specified by:
getTypeVariableMap
in interfaceTypeInformation<S>
- Returns:
-
createInfo
protected TypeInformation<?> createInfo(Type fieldType)
CreatesTypeInformation
for the givenType
.- Parameters:
fieldType
-- Returns:
-
resolveClass
protected Class<S> resolveClass(Type type)
Resolves the given type into a plainClass
.- Parameters:
type
-- Returns:
-
resolveType
protected Type resolveType(Type type)
Resolves the given type into aType
.- Parameters:
type
-- Returns:
-
getParameterTypes
public List<TypeInformation<?>> getParameterTypes(Constructor<?> constructor)
Description copied from interface:TypeInformation
Returns theTypeInformation
s for the parameters of the givenConstructor
.- Specified by:
getParameterTypes
in interfaceTypeInformation<S>
- Parameters:
constructor
- must not benull
.- Returns:
-
getGenericType
public Type getGenericType()
- Specified by:
getGenericType
in interfaceTypeInformation<S>
-
getActualType
public TypeInformation<?> getActualType()
Description copied from interface:TypeInformation
Transparently returns theMap
value type if the type is aMap
, returns the component type if the typeTypeInformation.isCollectionLike()
or the simple type if none of this applies.- Specified by:
getActualType
in interfaceTypeInformation<S>
- Returns:
-
isMap
public boolean isMap()
Description copied from interface:TypeInformation
Returns whether the property is aMap
. If this returnstrue
you can expectTypeInformation.getComponentType()
as well asTypeInformation.getMapValueType()
to return something notnull
.- Specified by:
isMap
in interfaceTypeInformation<S>
- Returns:
-
getMapValueType
public TypeInformation<?> getMapValueType()
Description copied from interface:TypeInformation
Will return the type of the value in case the underlying type is aMap
.- Specified by:
getMapValueType
in interfaceTypeInformation<S>
- Returns:
-
doGetMapValueType
protected TypeInformation<?> doGetMapValueType()
-
isCollectionLike
public boolean isCollectionLike()
Description copied from interface:TypeInformation
Returns whether the type can be considered a collection, which means it's a container of elements, e.g. aCollection
andArray
or anything implementingIterable
. If this returnstrue
you can expectTypeInformation.getComponentType()
to return a non-null
value.- Specified by:
isCollectionLike
in interfaceTypeInformation<S>
- Returns:
-
getComponentType
public final TypeInformation<?> getComponentType()
Description copied from interface:TypeInformation
Returns the component type forCollection
s or the key type forMap
s.- Specified by:
getComponentType
in interfaceTypeInformation<S>
- Returns:
-
doGetComponentType
protected TypeInformation<?> doGetComponentType()
-
getReturnType
public TypeInformation<?> getReturnType(Method method)
Description copied from interface:TypeInformation
Returns aTypeInformation
for the return type of the givenMethod
. Will potentially resolve generics information against the current types type parameter bindings.- Specified by:
getReturnType
in interfaceTypeInformation<S>
- Parameters:
method
- must not benull
.- Returns:
-
getParameterTypes
public List<TypeInformation<?>> getParameterTypes(Method method)
Description copied from interface:TypeInformation
Returns theTypeInformation
s for the parameters of the givenMethod
.- Specified by:
getParameterTypes
in interfaceTypeInformation<S>
- Parameters:
method
- must not benull
.- Returns:
-
getSuperTypeInformation
public TypeInformation<?> getSuperTypeInformation(Class<?> superType)
Description copied from interface:TypeInformation
Returns theTypeInformation
for the given raw super type.- Specified by:
getSuperTypeInformation
in interfaceTypeInformation<S>
- Parameters:
superType
- must not benull
.- Returns:
- the
TypeInformation
for the given raw super type ornull
in case the currentTypeInformation
does not implement the given type.
-
getTypeArguments
public List<TypeInformation<?>> getTypeArguments()
Description copied from interface:TypeInformation
Returns theTypeInformation
for the type arguments of the currentTypeInformation
.- Specified by:
getTypeArguments
in interfaceTypeInformation<S>
- Returns:
-
getTypeArgument
public TypeInformation<?> getTypeArgument(Class<?> bound, int index)
-
-