Package io.lettuce.core.dynamic.support
Class TypeVariableTypeInformation<T>
- java.lang.Object
-
- io.lettuce.core.dynamic.support.TypeVariableTypeInformation<T>
-
- All Implemented Interfaces:
TypeInformation<T>
public class TypeVariableTypeInformation<T> extends Object
SpecialTypeDiscoverer
to determine the actual type for aTypeVariable
. Will consider the context theTypeVariable
is being used in.
-
-
Constructor Summary
Constructors Constructor Description TypeVariableTypeInformation(TypeVariable<?> variable, Type owningType, io.lettuce.core.dynamic.support.TypeDiscoverer<?> parent, Map<TypeVariable<?>,Type> typeVariableMap)
Creates a bewTypeVariableTypeInformation
for the givenTypeVariable
owningType
and parentTypeDiscoverer
.
-
Method Summary
All 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)
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<T>
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.String
getVariableName()
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()
-
-
-
Constructor Detail
-
TypeVariableTypeInformation
public TypeVariableTypeInformation(TypeVariable<?> variable, Type owningType, io.lettuce.core.dynamic.support.TypeDiscoverer<?> parent, Map<TypeVariable<?>,Type> typeVariableMap)
Creates a bewTypeVariableTypeInformation
for the givenTypeVariable
owningType
and parentTypeDiscoverer
.- Parameters:
variable
- must not benull
owningType
- must not benull
parent
- can be benull
typeVariableMap
- must not benull
-
-
Method Detail
-
getType
public Class<T> 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<T>
- Returns:
-
getTypeArguments
public List<TypeInformation<?>> getTypeArguments()
Description copied from interface:TypeInformation
Returns theTypeInformation
for the type arguments of the currentTypeInformation
.- Specified by:
getTypeArguments
in interfaceTypeInformation<T>
- Returns:
-
equals
public boolean equals(Object obj)
-
hashCode
public int hashCode()
-
getVariableName
public String getVariableName()
-
createInfo
protected TypeInformation<?> createInfo(Type fieldType)
CreatesTypeInformation
for the givenType
.- Returns:
-
getTypeVariableMap
public Map<TypeVariable<?>,Type> getTypeVariableMap()
Returns the type variable map.- Specified by:
getTypeVariableMap
in interfaceTypeInformation<S>
- 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>
-
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:
-
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.
-
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:
-
getTypeArgument
public TypeInformation<?> getTypeArgument(Class<?> bound, int index)
-
-