Package com.zfabrik.resources

## Class TypeRef<T>

- java.lang.Object
- - com.zfabrik.resources.TypeRef<T>

-     public abstract class TypeRef<T>
      extends java.lang.Object

  A simple type reference to the be used to convey generic type information to type safe APIs such as `IResourceLookup.lookup(String, com.zfabrik.resources.TypeRef)`. Based on the approach outlined in Neil Gafter's blog.

- - ### Constructor Summary

    Constructors
    Modifier | Constructor | Description
    --- | --- | ---
    `` | `TypeRef()` |
    `protected` | `TypeRef​(java.lang.Class<T> clz)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `T` | `cast​(java.lang.Object o)` | A cast method to T.
    `boolean` | `equals​(java.lang.Object obj)` |
    `java.lang.Class<T>` | `getClz()` | Returns the represented class type, if this is what is represented.
    `java.lang.Class<T>` | `getClz​(boolean required)` | Returns the represented class type, if this is what is represented.
    `java.lang.reflect.Type` | `getType()` | Return the type of the type parameter.
    `int` | `hashCode()` |
    `java.lang.String` | `toString()` |

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

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### TypeRef

          public TypeRef()

    - #### TypeRef

          protected TypeRef​(java.lang.Class<T> clz)

  - ### Method Detail

    - #### getType

          public java.lang.reflect.Type getType()

      Return the type of the type parameter.

    - #### getClz

          public java.lang.Class<T> getClz()

      Returns the represented class type, if this is what is represented. Otherwise return `null`

    - #### cast

          public T cast​(java.lang.Object o)

      A cast method to T. Simply to avoid having using code handle warning for casts to parameterized types

    - #### getClz

          public java.lang.Class<T> getClz​(boolean required)

      Returns the represented class type, if this is what is represented. Otherwise return `null`, if required is passed as `false`. Throws an `IllegalStateException`, if no class type is represented and required is set to `true`. Returns `null`, if no class type is represented and required is set to `false`.

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `java.lang.Object`

    - #### equals

          public boolean equals​(java.lang.Object obj)

      Overrides:
        `equals` in class `java.lang.Object`

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`