Package io.lettuce.core.dynamic.support
Interface TypeInformation<S>
-
- All Known Implementing Classes:
ClassTypeInformation
,TypeVariableTypeInformation
public interface TypeInformation<S>
Interface to access types and resolving generics on the way.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description TypeInformation<?>
getActualType()
Transparently returns theMap
value type if the type is aMap
, returns the component type if the typeisCollectionLike()
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.List<TypeInformation<?>>
getTypeArguments()
Returns theTypeInformation
for the type arguments of the currentTypeInformation
.Map<TypeVariable<?>,Type>
getTypeVariableMap()
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
.
-
-
-
Method Detail
-
getGenericType
Type getGenericType()
-
getParameterTypes
List<TypeInformation<?>> getParameterTypes(Constructor<?> constructor)
Returns theTypeInformation
s for the parameters of the givenConstructor
.- Parameters:
constructor
- must not benull
.- Returns:
-
isCollectionLike
boolean isCollectionLike()
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 expectgetComponentType()
to return a non-null
value.- Returns:
-
getComponentType
TypeInformation<?> getComponentType()
Returns the component type forCollection
s or the key type forMap
s.- Returns:
-
isMap
boolean isMap()
Returns whether the property is aMap
. If this returnstrue
you can expectgetComponentType()
as well asgetMapValueType()
to return something notnull
.- Returns:
-
getMapValueType
TypeInformation<?> getMapValueType()
Will return the type of the value in case the underlying type is aMap
.- Returns:
-
getType
Class<S> getType()
Returns the type of the property. Will resolve generics and the generic context of- Returns:
-
getRawTypeInformation
ClassTypeInformation<?> getRawTypeInformation()
Returns aClassTypeInformation
to represent theTypeInformation
of the raw type of the current instance.- Returns:
-
getActualType
TypeInformation<?> getActualType()
Transparently returns theMap
value type if the type is aMap
, returns the component type if the typeisCollectionLike()
or the simple type if none of this applies.- Returns:
-
getReturnType
TypeInformation<?> getReturnType(Method method)
Returns aTypeInformation
for the return type of the givenMethod
. Will potentially resolve generics information against the current types type parameter bindings.- Parameters:
method
- must not benull
.- Returns:
-
getParameterTypes
List<TypeInformation<?>> getParameterTypes(Method method)
Returns theTypeInformation
s for the parameters of the givenMethod
.- Parameters:
method
- must not benull
.- Returns:
-
getSuperTypeInformation
TypeInformation<?> getSuperTypeInformation(Class<?> superType)
Returns theTypeInformation
for the given raw super type.- 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
boolean isAssignableFrom(TypeInformation<?> target)
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>
.- Parameters:
target
-- Returns:
-
getTypeArguments
List<TypeInformation<?>> getTypeArguments()
Returns theTypeInformation
for the type arguments of the currentTypeInformation
.- Returns:
-
getTypeVariableMap
Map<TypeVariable<?>,Type> getTypeVariableMap()
-
-