Class TypeReference<T extends Type>

    • Field Detail

      • ARRAY_SUFFIX

        protected static java.util.regex.Pattern ARRAY_SUFFIX
    • Constructor Detail

      • TypeReference

        protected TypeReference()
      • TypeReference

        protected TypeReference​(boolean indexed)
    • Method Detail

      • 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 TypeTypeReference<T> create​(java.lang.Class<T> cls)
      • create

        public static <T extends TypeTypeReference<T> create​(java.lang.Class<T> cls,
                                                               boolean indexed)
      • getAtomicTypeClass

        protected static java.lang.Class<? extends Type> getAtomicTypeClass​(java.lang.String solidityType,
                                                                            boolean primitives)
                                                                     throws java.lang.ClassNotFoundException
        This is a helper method that only works for atomic types (uint, bytes, etc). Array types must be wrapped by a ParameterizedType.
        Parameters:
        solidityType - the solidity as a string eg Address Int
        primitives - is it a primitive type
        Returns:
        returns
        Throws:
        java.lang.ClassNotFoundException - when the class cannot be found.
      • makeTypeReference

        public static TypeReference makeTypeReference​(java.lang.String solidityType)
                                               throws java.lang.ClassNotFoundException
        Create a TypeReference instance using solidity type string.
        Parameters:
        solidityType - A solidity type string to make TypeReference.
        Returns:
        TypeReference
        Throws:
        java.lang.ClassNotFoundException
      • makeTypeReference

        public static TypeReference makeTypeReference​(java.lang.String solidityType,
                                                      boolean indexed,
                                                      boolean primitives)
                                               throws java.lang.ClassNotFoundException
        Create a TypeReference instance using solidity type string.
        Parameters:
        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.
        Returns:
        TypeReference
        Throws:
        java.lang.ClassNotFoundException
      • makeStructTypeReference

        public static TypeReference makeStructTypeReference​(java.lang.String tupleString)
                                                     throws java.lang.ClassNotFoundException
        Creates a StructTypeReference instance using tupleString.
        Parameters:
        tupleString - A tuple type string
        Returns:
        StructTypeReference
        Throws:
        java.lang.ClassNotFoundException