org.jboss.resteasy.util

## Class GenericType<T>

- java.lang.Object
- - org.jboss.resteasy.util.GenericType<T>

-     public class GenericType<T>
      extends Object

  This class is a trick used to extract GenericType information at runtime. Java does not allow you get generic type information easily, so this class does the trick. For example:

       Type genericType = (new GenericType>() {}).getGenericType();

  The above code will get you the genericType for List
  Version:
    $Revision: 1 $
  Author:
    Bill Burke

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `GenericType()` Constructs a new generic entity.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `Type` | `getGenericType()` Gets underlying `Type` instance.
    `Class<T>` | `getType()` Gets the raw type of the enclosed entity.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### GenericType

          protected GenericType()

      Constructs a new generic entity. Derives represented class from type parameter. Note that this constructor is protected, users should create a (usually anonymous) subclass as shown above.
      Parameters:
        `entity` - the entity instance, must not be null
      Throws:
        `IllegalArgumentException` - if entity is null

  - ### Method Detail

    - #### getType

          public final Class<T> getType()

      Gets the raw type of the enclosed entity. Note that this is the raw type of the instance, not the raw type of the type parameter. I.e. in the example in the introduction, the raw type is `ArrayList` not `List`.
      Returns:
        the raw type

    - #### getGenericType

          public final Type getGenericType()

      Gets underlying `Type` instance. Note that this is derived from the type parameter, not the enclosed instance. I.e. in the example in the introduction, the type is `List<String>` not `ArrayList<String>`.
      Returns:
        the type

Copyright © 2014. All Rights Reserved.