Class TypeRef<T>

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

public abstract class TypeRef<T> extends 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 Details

    • TypeRef

      public TypeRef()
    • TypeRef

      protected TypeRef(Class<T> clz)
  • Method Details

    • getType

      public Type getType()
      Return the type of the type parameter.
    • getClz

      public Class<T> getClz()
      Returns the represented class type, if this is what is represented. Otherwise return null
    • cast

      public T cast(Object o)
      A cast method to T. Simply to avoid having using code handle warning for casts to parameterized types
    • getClz

      public 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 Object
    • equals

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

      public String toString()
      Overrides:
      toString in class Object