Spring Data Commons

org.springframework.data.util
Class ParentTypeAwareTypeInformation<S>

java.lang.Object
  extended by org.springframework.data.util.ParentTypeAwareTypeInformation<S>
All Implemented Interfaces:
TypeInformation<S>

public abstract class ParentTypeAwareTypeInformation<S>
extends java.lang.Object

Base class for TypeInformation implementations that need parent type awareness.

Author:
Oliver Gierke

Constructor Summary
protected ParentTypeAwareTypeInformation(java.lang.reflect.Type type, org.springframework.data.util.TypeDiscoverer<?> parent, java.util.Map<java.lang.reflect.TypeVariable,java.lang.reflect.Type> map)
          Creates a new ParentTypeAwareTypeInformation.
 
Method Summary
protected  TypeInformation<?> createInfo(java.lang.reflect.Type fieldType)
          Creates TypeInformation for the given Type.
 boolean equals(java.lang.Object obj)
           
 TypeInformation<?> getActualType()
          Transparently returns the Map value type if the type is a Map, returns the component type if the type TypeInformation.isCollectionLike() or the simple type if none of this applies.
 TypeInformation<?> getComponentType()
          Returns the component type for Collections or the key type for Maps.
 TypeInformation<?> getMapValueType()
          Will return the type of the value in case the underlying type is a Map.
 java.util.List<TypeInformation<?>> getParameterTypes(java.lang.reflect.Constructor<?> constructor)
           
 TypeInformation<?> getProperty(java.lang.String fieldname)
          Returns the property information for the property with the given name.
 TypeInformation<?> getReturnType(java.lang.reflect.Method method)
          Returns a TypeInformation for the return type of the given Method.
 java.lang.Class<S> getType()
          Returns the type of the property.
protected  java.util.Map<java.lang.reflect.TypeVariable,java.lang.reflect.Type> getTypeVariableMap()
          Considers the parent's type variable map before invoking the super class method.
 int hashCode()
           
 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.
protected  java.lang.Class<S> resolveType(java.lang.reflect.Type type)
          Resolves the given type into a plain Class.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParentTypeAwareTypeInformation

protected ParentTypeAwareTypeInformation(java.lang.reflect.Type type,
                                         org.springframework.data.util.TypeDiscoverer<?> parent,
                                         java.util.Map<java.lang.reflect.TypeVariable,java.lang.reflect.Type> map)
Creates a new ParentTypeAwareTypeInformation.

Parameters:
type -
typeVariableMap -
Method Detail

getTypeVariableMap

protected java.util.Map<java.lang.reflect.TypeVariable,java.lang.reflect.Type> getTypeVariableMap()
Considers the parent's type variable map before invoking the super class method.

Returns:

createInfo

protected TypeInformation<?> createInfo(java.lang.reflect.Type fieldType)
Creates TypeInformation for the given Type.

Returns:

equals

public boolean equals(java.lang.Object obj)

hashCode

public int hashCode()

resolveType

protected java.lang.Class<S> resolveType(java.lang.reflect.Type type)
Resolves the given type into a plain Class.

Parameters:
type -
Returns:

getParameterTypes

public java.util.List<TypeInformation<?>> getParameterTypes(java.lang.reflect.Constructor<?> constructor)
Specified by:
getParameterTypes in interface TypeInformation<S>

getProperty

public TypeInformation<?> getProperty(java.lang.String fieldname)
Description copied from interface: TypeInformation
Returns the property information for the property with the given name. Supports proeprty traversal through dot notation.

Specified by:
getProperty in interface TypeInformation<S>
Returns:

getType

public java.lang.Class<S> getType()
Description copied from interface: TypeInformation
Returns the type of the property. Will resolve generics and the generic context of

Specified by:
getType in interface TypeInformation<S>
Returns:

getActualType

public TypeInformation<?> getActualType()
Description copied from interface: TypeInformation
Transparently returns the Map value type if the type is a Map, returns the component type if the type TypeInformation.isCollectionLike() or the simple type if none of this applies.

Specified by:
getActualType in interface TypeInformation<S>
Returns:

isMap

public boolean isMap()
Description copied from interface: TypeInformation
Returns whether the property is a Map. If this returns true you can expect TypeInformation.getComponentType() as well as TypeInformation.getMapValueType() to return something not null.

Specified by:
isMap in interface TypeInformation<S>
Returns:

getMapValueType

public TypeInformation<?> getMapValueType()
Description copied from interface: TypeInformation
Will return the type of the value in case the underlying type is a Map.

Specified by:
getMapValueType in interface TypeInformation<S>
Returns:

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. a Collection and Array or anything implementing Iterable. If this returns true you can expect TypeInformation.getComponentType() to return a non-null value.

Specified by:
isCollectionLike in interface TypeInformation<S>
Returns:

getComponentType

public TypeInformation<?> getComponentType()
Description copied from interface: TypeInformation
Returns the component type for Collections or the key type for Maps.

Specified by:
getComponentType in interface TypeInformation<S>
Returns:

getReturnType

public TypeInformation<?> getReturnType(java.lang.reflect.Method method)
Description copied from interface: TypeInformation
Returns a TypeInformation for the return type of the given Method. Will potentially resolve generics information against the current types type parameter bindings.

Specified by:
getReturnType in interface TypeInformation<S>
Parameters:
method - must not be null.
Returns:

Spring Data Commons

Copyright © 2012. All Rights Reserved.