public abstract class TypeReference<T extends Type> extends java.lang.Object implements java.lang.Comparable<TypeReference<T>>
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.
Modifier and Type | Class and Description |
---|---|
static class |
TypeReference.StaticArrayTypeReference<T extends Type>
Type wrapper class for static array type.
|
static class |
TypeReference.StructTypeReference<T extends Type>
Type wrapper class for Struct type(StaticStruct, DynamicStruct).
|
Modifier and Type | Field and Description |
---|---|
protected static java.util.regex.Pattern |
ARRAY_SUFFIX |
Modifier | Constructor and Description |
---|---|
protected |
TypeReference() |
protected |
TypeReference(boolean indexed) |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(TypeReference<T> o) |
static <T extends Type> |
create(java.lang.Class<T> cls) |
static <T extends Type> |
create(java.lang.Class<T> cls,
boolean indexed) |
protected static java.lang.Class<? extends Type> |
getAtomicTypeClass(java.lang.String solidityType,
boolean primitives)
This is a helper method that only works for atomic types (uint, bytes, etc).
|
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 via
Class<T> . |
java.lang.reflect.Type |
getType() |
boolean |
isIndexed() |
static TypeReference |
makeStructTypeReference(java.lang.String tupleString)
Creates a StructTypeReference instance using tupleString.
|
static TypeReference |
makeTypeReference(java.lang.String solidityType)
Create a TypeReference instance using solidity type string.
|
static TypeReference |
makeTypeReference(java.lang.String solidityType,
boolean indexed,
boolean primitives)
Create a TypeReference instance using solidity type string.
|
protected TypeReference()
protected TypeReference(boolean indexed)
public int compareTo(TypeReference<T> o)
compareTo
in interface java.lang.Comparable<TypeReference<T extends Type>>
public java.lang.reflect.Type getType()
public boolean isIndexed()
public java.lang.Class<T> getClassType() throws java.lang.ClassNotFoundException
Class<T>
.java.lang.ClassNotFoundException
- if the class type cannot be determinedpublic static <T extends Type> TypeReference<T> create(java.lang.Class<T> cls)
public static <T extends Type> TypeReference<T> create(java.lang.Class<T> cls, boolean indexed)
protected static java.lang.Class<? extends Type> getAtomicTypeClass(java.lang.String solidityType, boolean primitives) throws java.lang.ClassNotFoundException
ParameterizedType
.solidityType
- the solidity as a string eg Address Intprimitives
- is it a primitive typejava.lang.ClassNotFoundException
- when the class cannot be found.public static TypeReference makeTypeReference(java.lang.String solidityType) throws java.lang.ClassNotFoundException
solidityType
- A solidity type string to make TypeReference.java.lang.ClassNotFoundException
public static TypeReference makeTypeReference(java.lang.String solidityType, boolean indexed, boolean primitives) throws java.lang.ClassNotFoundException
solidityType
- A solidity type string to make TypeReference.indexed
- true if the field is part of the log's topics, false if it one of the logs data.primitives
- If true, a TypeReference instance is created with a type representing the range of the passed integer type.java.lang.ClassNotFoundException
public static TypeReference makeStructTypeReference(java.lang.String tupleString) throws java.lang.ClassNotFoundException
tupleString
- A tuple type stringjava.lang.ClassNotFoundException