Package org.fisco.bcos.sdk.abi
Class TypeReference<T extends Type>
java.lang.Object
org.fisco.bcos.sdk.abi.TypeReference<T>
- All Implemented Interfaces:
java.lang.Comparable<TypeReference<T>>
public abstract class TypeReference<T extends Type> extends java.lang.Object implements java.lang.Comparable<TypeReference<T>>
Type wrapper to get around limitations of Java's type erasure. This is so that we can pass around
Typed
Array
types.
See this blog post for further details.
It may make sense to switch to using Java's reflection Type to avoid working around this fundamental generics limitation.
-
Constructor Summary
Constructors Modifier Constructor Description protected
TypeReference()
protected
TypeReference(boolean indexed)
-
Method Summary
Modifier and Type Method Description int
compareTo(TypeReference<T> o)
static <T extends Type>
TypeReference<T>create(java.lang.Class<T> cls)
static <T extends Type>
TypeReference<T>create(java.lang.Class<T> cls, boolean indexed)
java.lang.Class<T>
getClassType()
Workaround to ensure type does not come back as T due to erasure, this enables you to create a TypeReference viaClass<T>
.java.lang.reflect.Type
getType()
boolean
isIndexed()
-
Constructor Details
-
TypeReference
protected TypeReference() -
TypeReference
protected TypeReference(boolean indexed)
-
-
Method Details
-
compareTo
-
getType
public java.lang.reflect.Type getType() -
isIndexed
public boolean isIndexed() -
getClassType
Workaround to ensure type does not come back as T due to erasure, this enables you to create a TypeReference viaClass<T>
.- Returns:
- the parameterized Class type if applicable, otherwise a regular class
- Throws:
java.lang.ClassNotFoundException
- if the class type cannot be determined
-
create
-
create
-