Package org.springframework.data.util
Class ClassTypeInformation<S>
java.lang.Object
org.springframework.data.util.ClassTypeInformation<S>
- All Implemented Interfaces:
TypeInformation<S>
TypeInformation
for a plain Class
.- Author:
- Oliver Gierke, Christoph Strobl
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ClassTypeInformation<Collection>
static final ClassTypeInformation<List>
static final ClassTypeInformation<Map>
protected static final Class<?>[]
static final ClassTypeInformation<Object>
static final ClassTypeInformation<Set>
-
Method Summary
Modifier and TypeMethodDescriptionprotected TypeInformation<?>
createInfo
(Type fieldType) CreatesTypeInformation
for the givenType
.protected TypeInformation<?>
protected TypeInformation<?>
boolean
static <S> ClassTypeInformation<S>
Simple factory method to easily create new instances ofClassTypeInformation
.static <S> TypeInformation<S>
fromReturnTypeOf
(Method method) Creates aTypeInformation
from the given method's return type.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.final TypeInformation<?>
Returns the component type forCollection
s or the key type forMap
s.protected Class<?>
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
.getProperty
(String fieldname) Returns the property information for the property with the given name.Returns aClassTypeInformation
to represent theTypeInformation
of the raw type of the current instance.getReturnType
(Method method) Returns aTypeInformation
for the return type of the givenMethod
.getSuperTypeInformation
(Class<?> superType) Returns theTypeInformation
for the given raw super type.getType()
Returns the type of the property.List<TypeInformation<?>>
Returns theTypeInformation
for the type arguments of the currentTypeInformation
.protected Map<TypeVariable<?>,
Type> Returns the type variable map.int
hashCode()
boolean
isAssignableFrom
(TypeInformation<?> target) Returns if the currentTypeInformation
can be safely assigned to the given one.boolean
Returns whether the type can be considered a collection, which means it's a container of elements, e.g. aCollection
andArray
or anything implementingIterable
.boolean
isMap()
Returns whether the property is aMap
.protected boolean
resolveType
(Type type) Resolves the given type into a plainClass
.TypeInformation<? extends S>
specialize
(ClassTypeInformation<?> type) Specializes the given (raw)ClassTypeInformation
using the context of the current potentially parameterized type, basically turning the given raw type into a parameterized one.toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.springframework.data.util.TypeInformation
getRequiredActualType, getRequiredComponentType, getRequiredMapValueType, getRequiredProperty, getRequiredSuperTypeInformation, getUserTypeInformation, isSubTypeOf
-
Field Details
-
COLLECTION
-
LIST
-
SET
-
MAP
-
OBJECT
-
MAP_TYPES
-
-
Method Details
-
from
Simple factory method to easily create new instances ofClassTypeInformation
.- Type Parameters:
S
-- Parameters:
type
- must not be null.- Returns:
-
fromReturnTypeOf
Creates aTypeInformation
from the given method's return type.- Parameters:
method
- must not be null.- Returns:
-
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
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
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:
-
specialize
Description copied from interface:TypeInformation
Specializes the given (raw)ClassTypeInformation
using the context of the current potentially parameterized type, basically turning the given raw type into a parameterized one. Will return the given type as is if no generics are involved.- Specified by:
specialize
in interfaceTypeInformation<S>
- Parameters:
type
- must not be null.- Returns:
- will never be null.
-
toString
-
getTypeVariableMap
Returns the type variable map.- Returns:
-
createInfo
CreatesTypeInformation
for the givenType
.- Parameters:
fieldType
- must not be null.- Returns:
-
resolveType
Resolves the given type into a plainClass
.- Parameters:
type
-- Returns:
-
getParameterTypes
Description copied from interface:TypeInformation
Returns theTypeInformation
s for the parameters of the givenConstructor
.- Specified by:
getParameterTypes
in interfaceTypeInformation<S>
- Parameters:
constructor
- must not be null.- Returns:
-
getProperty
Description copied from interface:TypeInformation
Returns the property information for the property with the given name. Supports property traversal through dot notation.- Specified by:
getProperty
in interfaceTypeInformation<S>
- Returns:
-
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:
- the map value, collection component type or the current type, null it the current type is a raw
Map
orCollection
.
-
isMap
public boolean isMap()Description copied from interface:TypeInformation
Returns whether the property is aMap
. If this returns true you can expectTypeInformation.getComponentType()
as well asTypeInformation.getMapValueType()
to return something not null.- Specified by:
isMap
in interfaceTypeInformation<S>
- Returns:
-
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
-
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 returns true you can expectTypeInformation.getComponentType()
to return a non-null value.- Specified by:
isCollectionLike
in interfaceTypeInformation<S>
- Returns:
-
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
-
getReturnType
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 be null.- Returns:
-
getParameterTypes
Description copied from interface:TypeInformation
Returns theTypeInformation
s for the parameters of the givenMethod
.- Specified by:
getParameterTypes
in interfaceTypeInformation<S>
- Parameters:
method
- must not be null.- Returns:
-
getSuperTypeInformation
Description copied from interface:TypeInformation
Returns theTypeInformation
for the given raw super type.- Specified by:
getSuperTypeInformation
in interfaceTypeInformation<S>
- Parameters:
superType
- must not be null.- Returns:
- the
TypeInformation
for the given raw super type or null in case the currentTypeInformation
does not implement the given type.
-
getTypeArguments
Description copied from interface:TypeInformation
Returns theTypeInformation
for the type arguments of the currentTypeInformation
.- Specified by:
getTypeArguments
in interfaceTypeInformation<S>
- Returns:
-
isMapBaseType
protected boolean isMapBaseType() -
getMapBaseType
-
equals
-
hashCode
public int hashCode()
-