ma.glasnost.orika.metadata
Class Type<T>

java.lang.Object
  extended by ma.glasnost.orika.metadata.Type<T>
Type Parameters:
T -
All Implemented Interfaces:
Comparable<Type<?>>, ParameterizedType, Type

public final class Type<T>
extends Object
implements ParameterizedType, Comparable<Type<?>>

Type is an implementation of ParameterizedType which may be used in various mapping methods where a Class instance would normally be used, in order to provide more specific details as to the actual types represented by the generic template parameters in a given class.

Such details are not normally available at runtime using a Class instance due to type-erasure.

Type essentially provides a runtime token to represent a ParameterizedType with fully-resolve actual type arguments; it will contain

Author:
matt.deboer@gmail.com

Method Summary
 int compareTo(Type<?> other)
           
 boolean equals(Object obj)
           
 Type<?> findAncestor(Class<?> ancestor)
          Finds a class or interface which is an ancestor of this type
 Type<?> findAncestor(Type<?> ancestor)
          Finds a class or interface which is an ancestor of this type
 Type<?> findInterface(Type<?> theInterface)
           
 Type[] getActualTypeArguments()
           
 String getCanonicalName()
           
 Type<?> getComponentType()
           
 Type<?>[] getInterfaces()
           
 String getName()
           
<X> Type<X>
getNestedType(int index)
          Get the nested Type of the specified index.
 Type getOwnerType()
           
 Type<?> getPrimitiveType()
           
 Class<T> getRawType()
           
 String getSimpleName()
           
 Type<?> getSuperType()
           
 Type getTypeByVariable(TypeVariable<?> typeVariable)
           
 Map<String,Type<?>> getTypesByVariable()
           
 Type<?> getWrapperType()
           
 int hashCode()
           
 boolean isArray()
           
 boolean isAssignableFrom(Class<?> other)
          Test whether this type is assignable from the other Class; returns true if this type is not parameterized and the raw type is assignable.
 boolean isAssignableFrom(Type<?> other)
          Test whether this type is assignable from the other type.
 boolean isCollection()
           
 boolean isConvertibleFromString()
           
 boolean isEnum()
           
 boolean isList()
           
 boolean isMap()
           
 boolean isMultiOccurrence()
           
 boolean isParameterized()
           
 boolean isPrimitive()
           
 boolean isPrimitiveFor(Type<?> wrapper)
           
 boolean isPrimitiveWrapper()
           
 boolean isString()
           
 boolean isWrapperFor(Type<?> primitive)
           
 String toFullyQualifiedString()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

isParameterized

public boolean isParameterized()
Returns:
true if the given type is parameterized by nested types

getNestedType

public <X> Type<X> getNestedType(int index)
Get the nested Type of the specified index.

Parameters:
index -
Returns:

getSuperType

public Type<?> getSuperType()
Returns:
the direct super-type of this type, with type arguments resolved with respect to the actual type arguments of this type.

getInterfaces

public Type<?>[] getInterfaces()
Returns:
the interfaces implemented by this type, with type arguments resolved with respect to the actual type arguments of this type.

getActualTypeArguments

public Type[] getActualTypeArguments()
Specified by:
getActualTypeArguments in interface ParameterizedType

getTypesByVariable

public Map<String,Type<?>> getTypesByVariable()

getTypeByVariable

public Type getTypeByVariable(TypeVariable<?> typeVariable)

getRawType

public Class<T> getRawType()
Specified by:
getRawType in interface ParameterizedType

getComponentType

public Type<?> getComponentType()

getOwnerType

public Type getOwnerType()
Specified by:
getOwnerType in interface ParameterizedType

getSimpleName

public String getSimpleName()

getName

public String getName()

getCanonicalName

public String getCanonicalName()

isAssignableFrom

public boolean isAssignableFrom(Type<?> other)
Test whether this type is assignable from the other type.

Parameters:
other -
Returns:

isAssignableFrom

public boolean isAssignableFrom(Class<?> other)
Test whether this type is assignable from the other Class; returns true if this type is not parameterized and the raw type is assignable.

Parameters:
other -
Returns:

isEnum

public boolean isEnum()

isArray

public boolean isArray()

isCollection

public boolean isCollection()

isList

public boolean isList()

isMap

public boolean isMap()

isMultiOccurrence

public boolean isMultiOccurrence()
Returns:
true if this type is a Map, Collection or Array

isString

public boolean isString()

isPrimitive

public boolean isPrimitive()

isPrimitiveWrapper

public boolean isPrimitiveWrapper()

isWrapperFor

public boolean isWrapperFor(Type<?> primitive)

isPrimitiveFor

public boolean isPrimitiveFor(Type<?> wrapper)

getWrapperType

public Type<?> getWrapperType()

findAncestor

public Type<?> findAncestor(Type<?> ancestor)
Finds a class or interface which is an ancestor of this type

Parameters:
ancestor -
Returns:

findAncestor

public Type<?> findAncestor(Class<?> ancestor)
Finds a class or interface which is an ancestor of this type

Parameters:
ancestor -
Returns:

findInterface

public Type<?> findInterface(Type<?> theInterface)

getPrimitiveType

public Type<?> getPrimitiveType()

isConvertibleFromString

public boolean isConvertibleFromString()

toString

public String toString()
Overrides:
toString in class Object

toFullyQualifiedString

public String toFullyQualifiedString()

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

compareTo

public int compareTo(Type<?> other)
Specified by:
compareTo in interface Comparable<Type<?>>


Copyright © 2013 Glasnost. All Rights Reserved.