Package com.zfabrik.resources
Class TypeRef<T>
- java.lang.Object
-
- com.zfabrik.resources.TypeRef<T>
-
public abstract class TypeRef<T> extends java.lang.ObjectA simple type reference to the be used to convey generic type information to type safe APIs such asIResourceLookup.lookup(String, com.zfabrik.resources.TypeRef). Based on the approach outlined in Neil Gafter's blog.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Tcast(java.lang.Object o)A cast method to T.booleanequals(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.TypegetType()Return the type of the type parameter.inthashCode()java.lang.StringtoString()
-
-
-
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 returnnull
-
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 returnnull, if required is passed asfalse. Throws anIllegalStateException, if no class type is represented and required is set totrue. Returnsnull, if no class type is represented and required is set tofalse.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-