public interface TypeInformation<S>
ClassTypeInformation
you can traverse properties using getProperty(String)
to access type information.Modifier and Type | Method and Description |
---|---|
TypeInformation<?> |
getActualType()
Transparently returns the
Map value type if the type is a Map , returns the
component type if the type isCollectionLike() or the simple type if none of this applies. |
TypeInformation<?> |
getComponentType()
Returns the component type for
Collection s or the key type for Map s. |
TypeInformation<?> |
getMapValueType()
Will return the type of the value in case the underlying type is a
Map . |
List<TypeInformation<?>> |
getParameterTypes(Constructor<?> constructor)
Returns the
TypeInformation s for the parameters of the given Constructor . |
List<TypeInformation<?>> |
getParameterTypes(Method method)
Returns the
TypeInformation s for the parameters of the given Method . |
TypeInformation<?> |
getProperty(String property)
Returns the property information for the property with the given name.
|
ClassTypeInformation<?> |
getRawTypeInformation()
Returns a
ClassTypeInformation to represent the TypeInformation of the raw type of the current
instance. |
default TypeInformation<?> |
getRequiredActualType()
Transparently returns the
Map value type if the type is a Map , returns the
component type if the type isCollectionLike() or the simple type if none of this applies. |
default TypeInformation<?> |
getRequiredComponentType()
Returns the component type for
Collection s, the key type for Map s or the single
generic type if available. |
default TypeInformation<?> |
getRequiredMapValueType()
Will return the type of the value in case the underlying type is a
Map or throw
IllegalStateException if the map value type cannot be resolved. |
default TypeInformation<?> |
getRequiredProperty(String property)
Returns the property information for the property with the given name or throw
IllegalArgumentException if
the type information cannot be resolved. |
default TypeInformation<?> |
getRequiredSuperTypeInformation(Class<?> superType)
Returns the
TypeInformation for the given raw super type. |
TypeInformation<?> |
getReturnType(Method method)
Returns a
TypeInformation for the return type of the given Method . |
TypeInformation<?> |
getSuperTypeInformation(Class<?> superType)
Returns the
TypeInformation for the given raw super type. |
Class<S> |
getType()
Returns the type of the property.
|
List<TypeInformation<?>> |
getTypeArguments()
Returns the
TypeInformation for the type arguments of the current TypeInformation . |
default TypeInformation<?> |
getUserTypeInformation()
Returns the user type of the property if proxied.
|
boolean |
isAssignableFrom(TypeInformation<?> target)
Returns if the current
TypeInformation 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. a
Collection and Array or anything implementing Iterable . |
boolean |
isMap()
Returns whether the property is a
Map . |
default boolean |
isSubTypeOf(Class<?> type)
Returns whether the current type is a sub type of the given one, i.e. whether it's assignable but not the same one.
|
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. |
List<TypeInformation<?>> getParameterTypes(Constructor<?> constructor)
TypeInformation
s for the parameters of the given Constructor
.constructor
- must not be null.@Nullable TypeInformation<?> getProperty(String property)
property
- default TypeInformation<?> getRequiredProperty(String property)
IllegalArgumentException
if
the type information cannot be resolved. Supports property traversal through dot notation.property
- IllegalArgumentException
- if the type information cannot be resolved.boolean isCollectionLike()
Collection
and Array
or anything implementing Iterable
. If this
returns true you can expect getComponentType()
to return a non-null value.@Nullable TypeInformation<?> getComponentType()
Collection
s or the key type for Map
s.default TypeInformation<?> getRequiredComponentType()
Collection
s, the key type for Map
s or the single
generic type if available. Throws IllegalStateException
if the component value type cannot be resolved.IllegalStateException
- if the component type cannot be resolved, e.g. if a raw type is used or the type is
not generic in the first place.boolean isMap()
Map
. If this returns true you can expect
getComponentType()
as well as getMapValueType()
to return something not null.@Nullable TypeInformation<?> getMapValueType()
Map
.default TypeInformation<?> getRequiredMapValueType()
Map
or throw
IllegalStateException
if the map value type cannot be resolved.IllegalStateException
- if the map value type cannot be resolved, usually due to the current
Map
type being a raw one.Class<S> getType()
default TypeInformation<?> getUserTypeInformation()
ProxyUtils.getUserClass(Class)
ClassTypeInformation<?> getRawTypeInformation()
ClassTypeInformation
to represent the TypeInformation
of the raw type of the current
instance.@Nullable TypeInformation<?> getActualType()
Map
value type if the type is a Map
, returns the
component type if the type isCollectionLike()
or the simple type if none of this applies.Map
or Collection
.default TypeInformation<?> getRequiredActualType()
Map
value type if the type is a Map
, returns the
component type if the type isCollectionLike()
or the simple type if none of this applies.IllegalArgumentException
- if the current type is a raw Map
or Collection
and no value or component type is available.TypeInformation<?> getReturnType(Method method)
TypeInformation
for the return type of the given Method
. Will potentially resolve
generics information against the current types type parameter bindings.method
- must not be null.List<TypeInformation<?>> getParameterTypes(Method method)
TypeInformation
s for the parameters of the given Method
.method
- must not be null.@Nullable TypeInformation<?> getSuperTypeInformation(Class<?> superType)
TypeInformation
for the given raw super type.superType
- must not be null.TypeInformation
for the given raw super type or null in case the current
TypeInformation
does not implement the given type.default TypeInformation<?> getRequiredSuperTypeInformation(Class<?> superType)
TypeInformation
for the given raw super type.superType
- must not be null.TypeInformation
for the given raw super type.IllegalArgumentException
- in case the current TypeInformation
does not implement the given type.boolean isAssignableFrom(TypeInformation<?> target)
TypeInformation
can be safely assigned to the given one. Mimics semantics of
Class.isAssignableFrom(Class)
but takes generics into account. Thus it will allow to detect that a
List<Long>
is assignable to List<? extends Number>
.target
- List<TypeInformation<?>> getTypeArguments()
TypeInformation
for the type arguments of the current TypeInformation
.TypeInformation<? extends S> specialize(ClassTypeInformation<?> type)
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.type
- must not be null.default boolean isSubTypeOf(Class<?> type)
type
- must not be null.Copyright © 2011–2022 Pivotal Software, Inc.. All rights reserved.