org.springframework.data.util

## Interface TypeInformation<S>

All Known Implementing Classes:
  ClassTypeInformation, ParentTypeAwareTypeInformation

    public interface TypeInformation<S>

Interface to access property types and resolving generics on the way. Starting with a `ClassTypeInformation` you can traverse properties using `getProperty(String)` to access type information.

Author:
  Oliver Gierke, Mark Paluch

### Method Summary

All Methods Instance Methods Abstract Methods Default Methods
`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`.
`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.

### Method Detail

#### getParameterTypes

    List<TypeInformation<?>> getParameterTypes(Constructor<?> constructor)

Returns the `TypeInformation`s for the parameters of the given `Constructor`.

Parameters:
  `constructor` - must not be null.
Returns:

#### getProperty

    @Nullable
    TypeInformation<?> getProperty(String property)

Returns the property information for the property with the given name. Supports property traversal through dot notation.

Parameters:
  `property` -
Returns:

#### getRequiredProperty

    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. Supports property traversal through dot notation.

Parameters:
  `property` -
Returns:
Throws:
  `IllegalArgumentException` - if the type information cannot be resolved.
Since:
  2.0

#### isCollectionLike

    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`. If this returns true you can expect `getComponentType()` to return a non-null value.

Returns:

#### getComponentType

    @Nullable
    TypeInformation<?> getComponentType()

Returns the component type for `Collection`s or the key type for `Map`s.

Returns:

#### getRequiredComponentType

    default TypeInformation<?> getRequiredComponentType()

Returns the component type for `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.

Returns:
Throws:
  `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.
Since:
  2.0

#### isMap

    boolean isMap()

Returns whether the property is a `Map`. If this returns true you can expect `getComponentType()` as well as `getMapValueType()` to return something not null.

Returns:

#### getMapValueType

    @Nullable
    TypeInformation<?> getMapValueType()

Will return the type of the value in case the underlying type is a `Map`.

Returns:

#### getRequiredMapValueType

    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.

Returns:
Throws:
  `IllegalStateException` - if the map value type cannot be resolved, usually due to the current `Map` type being a raw one.
Since:
  2.0

#### getType

    Class<S> getType()

Returns the type of the property. Will resolve generics and the generic context of

Returns:

#### getRawTypeInformation

    ClassTypeInformation<?> getRawTypeInformation()

Returns a `ClassTypeInformation` to represent the `TypeInformation` of the raw type of the current instance.

Returns:

#### getActualType

    @Nullable
    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.

Returns:
  the map value, collection component type or the current type, null it the current type is a raw `Map` or `Collection`.

#### getRequiredActualType

    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.

Returns:
Throws:
  `IllegalArgumentException` - if the current type is a raw `Map` or `Collection` and no value or component type is available.
Since:
  2.0

#### getReturnType

    TypeInformation<?> getReturnType(Method method)

Returns a `TypeInformation` for the return type of the given `Method`. Will potentially resolve generics information against the current types type parameter bindings.

Parameters:
  `method` - must not be null.
Returns:

#### getParameterTypes

    List<TypeInformation<?>> getParameterTypes(Method method)

Returns the `TypeInformation`s for the parameters of the given `Method`.

Parameters:
  `method` - must not be null.
Returns:

#### getSuperTypeInformation

    @Nullable
    TypeInformation<?> getSuperTypeInformation(Class<?> superType)

Returns the `TypeInformation` for the given raw super type.

Parameters:
  `superType` - must not be null.
Returns:
  the `TypeInformation` for the given raw super type or null in case the current `TypeInformation` does not implement the given type.

#### getRequiredSuperTypeInformation

    default TypeInformation<?> getRequiredSuperTypeInformation(Class<?> superType)

Returns the `TypeInformation` for the given raw super type.

Parameters:
  `superType` - must not be null.
Returns:
  the `TypeInformation` for the given raw super type.
Throws:
  `IllegalArgumentException` - in case the current `TypeInformation` does not implement the given type.
Since:
  2.0

#### isAssignableFrom

    boolean isAssignableFrom(TypeInformation<?> target)

Returns if the current `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>`.

Parameters:
  `target` -
Returns:

#### getTypeArguments

    List<TypeInformation<?>> getTypeArguments()

Returns the `TypeInformation` for the type arguments of the current `TypeInformation`.

Returns:

#### specialize

    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. Will return the given type as is if no generics are involved.

Parameters:
  `type` - must not be null.
Returns:
  will never be null.

#### isSubTypeOf

    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.

Parameters:
  `type` - must not be null.
Returns:
Since:
  2.2