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 class GenericType<T>
extends java.lang.Object

Represents a generic message entity type T. Supports in-line instantiation of objects that represent generic types with actual type parameters. An object that represents any parameterized type may be obtained by sub-classing GenericType. Alternatively, an object representing a concrete parameterized type can be created using a GenericType(java.lang.reflect.Type) and manually specifying the actual (parameterized) type.

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

Since:
2.0
Author:
Jerome Dochez, Marek Potociar, Paul Sandoz, Martin Matula

Constructor Summary
protected GenericType()
          Constructs a new generic type, deriving the generic type and class from type parameter.
  GenericType(java.lang.reflect.Type genericType)
          Constructs a new generic type, supplying the generic type information and deriving the class.
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 java.lang.Class<?> getRawType()
          Returns the object representing the class or interface that declared the type represented by this generic type instance.
 java.lang.reflect.Type getType()
          Retrieve the type represented by the generic type instance.
 int hashCode()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GenericType

protected GenericType()
Constructs a new generic type, deriving the generic type and class from type parameter. Note that this constructor is protected, users should create a (usually anonymous) subclass as shown above.


GenericType

public GenericType(java.lang.reflect.Type genericType)
Constructs a new generic type, supplying the generic type information and deriving the class.

Parameters:
genericType - the generic type.
Throws:
java.lang.IllegalArgumentException - if genericType is null or not an instance of Class or ParameterizedType whose raw type is an instance of Class.
Method Detail

getType

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

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

getRawType

public final java.lang.Class<?> 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(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


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