Class GenericObjectType


  • public class GenericObjectType
    extends org.apache.bcel.generic.ObjectType
    Extension to ObjectType that includes additional information about the generic signature.

    A GenericObjectType is either a parameterized type e.g. List<String>, or a type variable e.g. T.

    This class cannot be initialized directly. Instead, create a GenericObjectType by calling GenericUtilities.getType(String) and passing in the bytecode signature for the type.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) org.apache.bcel.generic.ReferenceType extension  
      (package private) java.util.List<? extends org.apache.bcel.generic.ReferenceType> parameters  
      (package private) java.lang.String variable  
      • Fields inherited from class org.apache.bcel.generic.Type

        BOOLEAN, BYTE, CHAR, CLASS, DOUBLE, FLOAT, INT, LONG, NO_ARGS, NULL, OBJECT, SHORT, signature, STRING, STRINGBUFFER, THROWABLE, type, UNKNOWN, VOID
    • Constructor Summary

      Constructors 
      Constructor Description
      GenericObjectType​(java.lang.String variable)
      Create a GenericObjectType that represents a Simple Type Variable or a simple wildcard with no extensions
      GenericObjectType​(java.lang.String class_name, java.util.List<? extends org.apache.bcel.generic.ReferenceType> parameters)
      Create a GenericObjectType that represents a parameterized class
      GenericObjectType​(java.lang.String wildcard, org.apache.bcel.generic.ReferenceType extension)
      Create a GenericObjectType that represents a Wildcard with extensions
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object o)  
      org.apache.bcel.generic.Type getExtension()  
      java.lang.String getGenericParametersAsString()  
      int getNumParameters()  
      org.apache.bcel.generic.ObjectType getObjectType()  
      org.apache.bcel.generic.ReferenceType getParameterAt​(int index)  
      java.util.List<? extends org.apache.bcel.generic.ReferenceType> getParameters()  
      GenericUtilities.TypeCategory getTypeCategory()
      Get the TypeCategory that represents this Object
      org.apache.bcel.generic.Type getUpperBound()  
      java.lang.String getVariable()  
      int hashCode()  
      boolean hasParameters()  
      org.apache.bcel.generic.ReferenceType produce()  
      java.lang.String toPlainString()  
      java.lang.String toString()  
      java.lang.String toString​(boolean includeGenerics)
      Return a string representation of this object.
      • Methods inherited from class org.apache.bcel.generic.ObjectType

        accessibleTo, getClassName, getInstance, referencesClass, referencesClassExact, referencesInterface, referencesInterfaceExact, subclassOf
      • Methods inherited from class org.apache.bcel.generic.ReferenceType

        firstCommonSuperclass, getFirstCommonSuperclass, isAssignmentCompatibleWith, isCastableTo
      • Methods inherited from class org.apache.bcel.generic.Type

        getArgumentTypes, getMethodSignature, getReturnType, getSignature, getSignature, getSize, getType, getType, getType, getTypes, normalizeForStackOrLocal
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • parameters

        final java.util.List<? extends org.apache.bcel.generic.ReferenceType> parameters
      • variable

        @CheckForNull
        final java.lang.String variable
      • extension

        @CheckForNull
        final org.apache.bcel.generic.ReferenceType extension
    • Constructor Detail

      • GenericObjectType

        GenericObjectType​(@Nonnull
                          java.lang.String variable)
        Create a GenericObjectType that represents a Simple Type Variable or a simple wildcard with no extensions
        Parameters:
        variable - the type variable e.g. T
      • GenericObjectType

        GenericObjectType​(@Nonnull
                          java.lang.String wildcard,
                          @CheckForNull
                          org.apache.bcel.generic.ReferenceType extension)
        Create a GenericObjectType that represents a Wildcard with extensions
      • GenericObjectType

        GenericObjectType​(@DottedClassName
                          java.lang.String class_name,
                          java.util.List<? extends org.apache.bcel.generic.ReferenceType> parameters)
        Create a GenericObjectType that represents a parameterized class
        Parameters:
        class_name - the class that is parameterized. e.g. java.util.List
        parameters - the parameters of this class, must be at least 1 parameter
    • Method Detail

      • produce

        public org.apache.bcel.generic.ReferenceType produce()
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class org.apache.bcel.generic.ObjectType
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class org.apache.bcel.generic.ObjectType
      • getUpperBound

        public org.apache.bcel.generic.Type getUpperBound()
      • getExtension

        public org.apache.bcel.generic.Type getExtension()
        Returns:
        Returns the extension.
      • getVariable

        public java.lang.String getVariable()
        Returns:
        Returns the variable.
      • hasParameters

        public boolean hasParameters()
        Returns:
        true if this GenericObjectType represents a parameterized type e.g. List<String>. This implies that isVariable() is falses
      • getNumParameters

        public int getNumParameters()
        Returns:
        the number of parameters if this is a parameterized class, 0 otherwise
      • getParameterAt

        public org.apache.bcel.generic.ReferenceType getParameterAt​(int index)
        Parameters:
        index - should be less than getNumParameters()
        Returns:
        the type parameter at index
      • getParameters

        @CheckForNull
        public java.util.List<? extends org.apache.bcel.generic.ReferenceType> getParameters()
      • getObjectType

        public org.apache.bcel.generic.ObjectType getObjectType()
        Returns:
        the underlying ObjectType for this Generic Object
      • toString

        public java.lang.String toString​(boolean includeGenerics)
        Return a string representation of this object. (I do not override toString() in case any existing code assumes that this object is an ObjectType and expects similar string representation. i.e. toString() is equivalent to toString(false))
        Parameters:
        includeGenerics - if true then the string includes generic information in this object. Otherwise this returns the same value as ObjectType.toString()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class org.apache.bcel.generic.Type
      • toPlainString

        public java.lang.String toPlainString()
      • getGenericParametersAsString

        public java.lang.String getGenericParametersAsString()