javax.ws.rs.core
Class GenericType<T>

java.lang.Object
  extended by javax.ws.rs.core.GenericType<T>
Type Parameters:
T - the generic type parameter.

public abstract class GenericType<T>
extends Object

Supports in-line instantiation of objects that represent parameterized types with actual type parameters. An object that represents any parameterized type may be obtained by sub-classing GenericType.

  GenericType<List<String>> stringListType = new GenericType<List<String>>() {};
 

Since:
2.0
Author:
Jerome Dochez, Marek Potociar

Constructor Summary
protected GenericType()
          Protected constructor for a generic type of a concrete Java type.
 
Method Summary
 boolean equals(Object obj)
           
 Type[] getParameterTypes()
          Retrieve an array of Type objects representing the actual type arguments to the type represented by this generic type instance.
 Class<T> getRawType()
          Returns the object representing the class or interface that declared the type represented by this generic type instance.
 Type getType()
          Retrieve the type represented by the generic type instance.
 int hashCode()
           
static
<T> GenericType<T>
of(Class<?> rawType, Type type)
          Construct a generic type instance with programmatically set values of type and raw type.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GenericType

protected GenericType()
Protected constructor for a generic type of a concrete Java type.

Method Detail

of

public static <T> GenericType<T> of(Class<?> rawType,
                                    Type type)
Construct a generic type instance with programmatically set values of type and raw type.

Type Parameters:
T - Java type.
Parameters:
rawType - raw parameter type.
type - parameter type (possibly generic).
Returns:
programmatically constructed generic type instance.

getType

public final Type getType()
Retrieve the type represented by the generic type instance.

Returns:
the actual type represented by this generic type instance.

getParameterTypes

public final Type[] getParameterTypes()
Retrieve an array of Type objects representing the actual type arguments to the type represented by this generic type instance.

Note that in some cases, the returned array may be empty. This can occur if the type represented by this generic type is a non-parameterized type.

Returns:
an array of Type objects representing the actual type arguments to this type.
Throws:
TypeNotPresentException - if any of the actual type arguments refers to a non-existent type declaration.
MalformedParameterizedTypeException - if any of the actual type parameters refer to a parameterized type that cannot be instantiated for any reason.

getRawType

public final Class<T> getRawType()
Returns the object representing the class or interface that declared the type represented by this generic type instance.

Returns:
the class or interface that declared the type represented by this generic type instance.

equals

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

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2007-2012 Oracle Corporation. All Rights Reserved. Use is subject to license terms.