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 via Class<T>.
    java.lang.reflect.Type getType()  
    boolean isIndexed()  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • compareTo

      public int compareTo​(TypeReference<T> o)
      Specified by:
      compareTo in interface java.lang.Comparable<T extends Type>
    • getType

      public java.lang.reflect.Type getType()
    • isIndexed

      public boolean isIndexed()
    • getClassType

      public java.lang.Class<T> getClassType() throws java.lang.ClassNotFoundException
      Workaround to ensure type does not come back as T due to erasure, this enables you to create a TypeReference via Class<T>.
      Returns:
      the parameterized Class type if applicable, otherwise a regular class
      Throws:
      java.lang.ClassNotFoundException - if the class type cannot be determined
    • create

      public static <T extends Type> TypeReference<T> create​(java.lang.Class<T> cls)
    • create

      public static <T extends Type> TypeReference<T> create​(java.lang.Class<T> cls, boolean indexed)