ma.glasnost.orika.metadata
Class TypeFactory

java.lang.Object
  extended by ma.glasnost.orika.metadata.TypeFactory

public abstract class TypeFactory
extends Object

TypeFactory contains various methods for obtaining a Type instance to represent various type situations.

Author:
matt.deboer@gmail.com

Field Summary
static Type<Object> TYPE_OF_OBJECT
          The Type instance which represents the Object class
 
Method Summary
static
<T> Type<T>
componentTypeOf(T[] object)
          Resolve the (element) component type for the given array.
static
<T> Type<T>
elementTypeOf(Iterable<T> object)
          Resolve the nested element type for the given Iterable.
static
<E> Type<E>
limitedValueOf(Class<E> rawType, Set<Type> recursiveBounds, Type... actualTypeArguments)
           
static
<T> Type<T>
limitedValueOf(ParameterizedType type, Set<Type> recursiveBounds)
          Return the Type for the given ParameterizedType, resolving actual type arguments where possible; uses recursiveBounds to limit the recursion.
static
<T> Type<T>
limitedValueOf(Type type, Set<Type> recursiveBounds)
          Return the Type for the given java.lang.reflect.Type, limiting the recursive depth on any type already contained in recursiveBounds.
static
<T> Type<T>
limitedValueOf(TypeVariable<?> var, Set<Type> recursiveBounds)
          Finds the Type value of the given TypeVariable, using recursiveBounds to limit the recursion.
static
<T> Type<T>
limitedValueOf(WildcardType var, Set<Type> recursiveBounds)
          Finds the Type value of the given wildcard type, using recursiveBounds to limit the recursion.
static
<T> Type<T>
resolveTypeOf(T object, Type<?> referenceType)
          Resolve the Type for the given object, using the provided referenceType to resolve the actual type arguments.
static
<T> Type<T>
resolveValueOf(Class<T> type, Type<?> referenceType)
          Resolve the Type for the given Class, using the provided referenceType to resolve the actual type arguments.
static
<T> Type<T>
resolveValueOf(ParameterizedType type, Type<?> referenceType)
          Resolve the Type for the given ParameterizedType, using the provided referenceType to resolve any unresolved actual type arguments.
static
<T> Type<T>
typeOf(T object)
          Return the Type for the given object.
static
<E> Type<E>
valueOf(Class<E> rawType)
          Resolves the Type value of the specified raw Class type
static
<E> Type<E>
valueOf(Class<E> rawType, Type... actualTypeArguments)
          Resolve the Type value of the given raw Class type, filling the type parameters with the provided actual type arguments
static
<T> Type<T>
valueOf(ParameterizedType type)
          Return the Type for the given ParameterizedType, resolving actual type arguments where possible.
static Type<?> valueOf(String typeDescriptor)
          Constructs a nested type from a string description of that type; allows for package names to be omitted for 'java.lang' and 'java.util' classes.
static
<T> Type<T>
valueOf(Type type)
          Return the Type for the given java.lang.reflect.Type, either for a ParameterizedType or a Class instance
static
<T> Type<T>
valueOf(Type<T> type)
          This method declaration helps to shortcut the other methods for ParameterizedType which it extends; we just return it.
static
<T> Type<T>
valueOf(TypeVariable<?> var)
          Finds the Type value of the given TypeVariable
static
<T> Type<T>
valueOf(WildcardType var)
          Finds the Type value of the given wildcard type
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE_OF_OBJECT

public static final Type<Object> TYPE_OF_OBJECT
The Type instance which represents the Object class

Method Detail

valueOf

public static <E> Type<E> valueOf(Class<E> rawType)
Resolves the Type value of the specified raw Class type

Parameters:
rawType -
Returns:
the resolved Type instance

limitedValueOf

public static <E> Type<E> limitedValueOf(Class<E> rawType,
                                         Set<Type> recursiveBounds,
                                         Type... actualTypeArguments)
Parameters:
rawType -
recursiveBounds -
actualTypeArguments -
Returns:
the resolved Type instance

valueOf

public static <E> Type<E> valueOf(Class<E> rawType,
                                  Type... actualTypeArguments)
Resolve the Type value of the given raw Class type, filling the type parameters with the provided actual type arguments

Parameters:
rawType -
actualTypeArguments -
Returns:
the resolved Type instance

valueOf

public static <T> Type<T> valueOf(Type<T> type)
This method declaration helps to shortcut the other methods for ParameterizedType which it extends; we just return it.

Parameters:
type -
Returns:
the resolved Type instance

valueOf

public static <T> Type<T> valueOf(ParameterizedType type)
Return the Type for the given ParameterizedType, resolving actual type arguments where possible.

Parameters:
type -
Returns:
the resolved Type instance

limitedValueOf

public static <T> Type<T> limitedValueOf(ParameterizedType type,
                                         Set<Type> recursiveBounds)
Return the Type for the given ParameterizedType, resolving actual type arguments where possible; uses recursiveBounds to limit the recursion.

Parameters:
type -
recursiveBounds -
Returns:
the resolved Type instance

valueOf

public static <T> Type<T> valueOf(TypeVariable<?> var)
Finds the Type value of the given TypeVariable

Parameters:
var -
Returns:
the resolved Type instance

limitedValueOf

public static <T> Type<T> limitedValueOf(TypeVariable<?> var,
                                         Set<Type> recursiveBounds)
Finds the Type value of the given TypeVariable, using recursiveBounds to limit the recursion.

Parameters:
var -
recursiveBounds -
Returns:
the resolved Type instance

valueOf

public static <T> Type<T> valueOf(WildcardType var)
Finds the Type value of the given wildcard type

Parameters:
var -
Returns:
the resolved Type instance

limitedValueOf

public static <T> Type<T> limitedValueOf(WildcardType var,
                                         Set<Type> recursiveBounds)
Finds the Type value of the given wildcard type, using recursiveBounds to limit the recursion.

Parameters:
var -
recursiveBounds -
Returns:
the resolved Type instance

valueOf

public static <T> Type<T> valueOf(Type type)
Return the Type for the given java.lang.reflect.Type, either for a ParameterizedType or a Class instance

Parameters:
type -
Returns:
the resolved Type instance

limitedValueOf

public static <T> Type<T> limitedValueOf(Type type,
                                         Set<Type> recursiveBounds)
Return the Type for the given java.lang.reflect.Type, limiting the recursive depth on any type already contained in recursiveBounds.

Parameters:
type -
recursiveBounds -
Returns:
the resolved Type instance

resolveValueOf

public static <T> Type<T> resolveValueOf(ParameterizedType type,
                                         Type<?> referenceType)
Resolve the Type for the given ParameterizedType, using the provided referenceType to resolve any unresolved actual type arguments.

Parameters:
type -
referenceType -
Returns:
the resolved Type instance

resolveValueOf

public static <T> Type<T> resolveValueOf(Class<T> type,
                                         Type<?> referenceType)
Resolve the Type for the given Class, using the provided referenceType to resolve the actual type arguments.

Parameters:
type -
referenceType -
Returns:
the resolved Type instance

typeOf

public static <T> Type<T> typeOf(T object)
Return the Type for the given object.

Parameters:
object -
Returns:
the resolved Type instance

resolveTypeOf

public static <T> Type<T> resolveTypeOf(T object,
                                        Type<?> referenceType)
Resolve the Type for the given object, using the provided referenceType to resolve the actual type arguments.

Parameters:
object -
referenceType -
Returns:
the resolved Type instance

componentTypeOf

public static <T> Type<T> componentTypeOf(T[] object)
Resolve the (element) component type for the given array.

Parameters:
object -
Returns:
the resolved Type instance

elementTypeOf

public static <T> Type<T> elementTypeOf(Iterable<T> object)
Resolve the nested element type for the given Iterable.

Parameters:
object -
Returns:
the resolved Type instance

valueOf

public static Type<?> valueOf(String typeDescriptor)
Constructs a nested type from a string description of that type; allows for package names to be omitted for 'java.lang' and 'java.util' classes.

Parameters:
typeDescriptor - a string representation of the java declaration of a generic type
Returns:


Copyright © 2013 Glasnost. All Rights Reserved.