com.googlecode.jtype
Class Types

java.lang.Object
  extended by com.googlecode.jtype.Types

public final class Types
extends java.lang.Object

Factory for creating types.

Version:
$Id: Types.java 37 2009-07-24 11:27:39Z markhobson $
Author:
Mark Hobson
See Also:
Type

Method Summary
static java.lang.reflect.GenericArrayType genericArrayType(java.lang.reflect.Type componentType)
          Creates a generic array type for the specified component type.
static java.lang.reflect.WildcardType lowerBoundedWildcardType(java.lang.reflect.Type lowerBound)
          Creates a wildcard type with the specified lower bound.
static java.lang.reflect.ParameterizedType parameterizedType(java.lang.Class<?> rawType, java.lang.reflect.Type... actualTypeArguments)
          Creates a parameterized type for the specified raw type and actual type arguments.
static
<D extends java.lang.reflect.GenericDeclaration>
java.lang.reflect.TypeVariable<D>
typeVariable(D declaration, java.lang.String name, java.lang.reflect.Type... bounds)
          Creates a type variable for the specified declaration, name and bounds.
static java.lang.reflect.WildcardType unboundedWildcardType()
          Creates an unbounded wildcard type.
static java.lang.reflect.WildcardType upperBoundedWildcardType(java.lang.reflect.Type upperBound)
          Creates a wildcard type with the specified upper bound.
static java.lang.reflect.Type valueOf(java.lang.String typeName)
          Returns a type that corresponds to the specified string.
static java.lang.reflect.Type valueOf(java.lang.String typeName, java.util.Set<java.lang.String> imports)
          Returns a type that corresponds to the specified string using the specified import context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

typeVariable

public static <D extends java.lang.reflect.GenericDeclaration> java.lang.reflect.TypeVariable<D> typeVariable(D declaration,
                                                                                                              java.lang.String name,
                                                                                                              java.lang.reflect.Type... bounds)
Creates a type variable for the specified declaration, name and bounds.

Type Parameters:
D - the type of generic declaration that declared the type variable
Parameters:
declaration - the generic declaration that declared the type variable
name - the name of the type variable
bounds - the upper bounds of the type variable
Returns:
the type variable

genericArrayType

public static java.lang.reflect.GenericArrayType genericArrayType(java.lang.reflect.Type componentType)
Creates a generic array type for the specified component type.

Parameters:
componentType - the component type
Returns:
the generic array type

parameterizedType

public static java.lang.reflect.ParameterizedType parameterizedType(java.lang.Class<?> rawType,
                                                                    java.lang.reflect.Type... actualTypeArguments)
Creates a parameterized type for the specified raw type and actual type arguments.

Parameters:
rawType - the raw type
actualTypeArguments - the actual type arguments
Returns:
the parameterized type
Throws:
java.lang.reflect.MalformedParameterizedTypeException - if the number of actual type arguments differs from those defined on the raw type

unboundedWildcardType

public static java.lang.reflect.WildcardType unboundedWildcardType()
Creates an unbounded wildcard type.

Returns:
the wildcard type

upperBoundedWildcardType

public static java.lang.reflect.WildcardType upperBoundedWildcardType(java.lang.reflect.Type upperBound)
Creates a wildcard type with the specified upper bound.

Parameters:
upperBound - the upper bound type
Returns:
the wildcard type

lowerBoundedWildcardType

public static java.lang.reflect.WildcardType lowerBoundedWildcardType(java.lang.reflect.Type lowerBound)
Creates a wildcard type with the specified lower bound.

Parameters:
lowerBound - the lower bound type
Returns:
the wildcard type

valueOf

public static java.lang.reflect.Type valueOf(java.lang.String typeName)
Returns a type that corresponds to the specified string.

Parameters:
typeName - the string to be parsed
Returns:
the type

valueOf

public static java.lang.reflect.Type valueOf(java.lang.String typeName,
                                             java.util.Set<java.lang.String> imports)
Returns a type that corresponds to the specified string using the specified import context.

Parameters:
typeName - the string to be parsed
imports - the fully qualified class names to use when an unqualified class name is encountered
Returns:
the type
Throws:
java.lang.IllegalArgumentException - if the import context contains duplicate entries for an unqualified class name


Copyright © 2011 Oracle Corporation. All Rights Reserved.