Class ParameterizedTypeImpl

  • All Implemented Interfaces:
    java.lang.reflect.ParameterizedType, java.lang.reflect.Type

    public class ParameterizedTypeImpl
    extends java.lang.Object
    implements java.lang.reflect.ParameterizedType
    ParameterizedType Implementation forks sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl
    Since:
    1.0.0
    Author:
    Mercy
    See Also:
    ParameterizedType, sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object o)  
      java.lang.reflect.Type[] getActualTypeArguments()
      Returns an array of Type objects representing the actual type arguments to this type.
      java.lang.reflect.Type getOwnerType()
      Returns a Type object representing the type that this type is a member of.
      java.lang.Class<?> getRawType()
      Returns the Type object representing the class or interface that declared this type.
      int hashCode()  
      static ParameterizedTypeImpl of​(java.lang.Class<?> rawType, java.lang.reflect.Type... actualTypeArguments)
      Static factory.
      static ParameterizedTypeImpl of​(java.lang.Class<?> rawType, java.lang.reflect.Type[] actualTypeArguments, java.lang.reflect.Type ownerType)
      Static factory.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.lang.reflect.Type

        getTypeName
    • Method Detail

      • of

        public static ParameterizedTypeImpl of​(java.lang.Class<?> rawType,
                                               java.lang.reflect.Type... actualTypeArguments)
        Static factory. Given a (generic) class, actual type arguments and an owner type, creates a parameterized type. This class can be instantiated with a a raw type that does not represent a generic type, provided the list of actual type arguments is empty. If the ownerType argument is null, the declaring class of the raw type is used as the owner type.

        This method throws a MalformedParameterizedTypeException under the following circumstances: If the number of actual type arguments (i.e., the size of the array typeArgs) does not correspond to the number of formal type arguments. If any of the actual type arguments is not an instance of the bounds on the corresponding formal.

        Parameters:
        rawType - the Class representing the generic type declaration being instantiated
        actualTypeArguments - - a (possibly empty) array of types representing the actual type arguments to the parameterized type
        Returns:
        An instance of ParameterizedType
        Throws:
        java.lang.reflect.MalformedParameterizedTypeException - - if the instantiation is invalid
      • of

        public static ParameterizedTypeImpl of​(java.lang.Class<?> rawType,
                                               java.lang.reflect.Type[] actualTypeArguments,
                                               java.lang.reflect.Type ownerType)
        Static factory. Given a (generic) class, actual type arguments and an owner type, creates a parameterized type. This class can be instantiated with a a raw type that does not represent a generic type, provided the list of actual type arguments is empty. If the ownerType argument is null, the declaring class of the raw type is used as the owner type.

        This method throws a MalformedParameterizedTypeException under the following circumstances: If the number of actual type arguments (i.e., the size of the array typeArgs) does not correspond to the number of formal type arguments. If any of the actual type arguments is not an instance of the bounds on the corresponding formal.

        Parameters:
        rawType - the Class representing the generic type declaration being instantiated
        actualTypeArguments - - a (possibly empty) array of types representing the actual type arguments to the parameterized type
        ownerType - - the enclosing type, if known.
        Returns:
        An instance of ParameterizedType
        Throws:
        java.lang.reflect.MalformedParameterizedTypeException - - if the instantiation is invalid
      • getActualTypeArguments

        public java.lang.reflect.Type[] getActualTypeArguments()
        Returns an array of Type objects representing the actual type arguments to this type.

        Note that in some cases, the returned array be empty. This can occur if this type represents a non-parameterized type nested within a parameterized type.

        Specified by:
        getActualTypeArguments in interface java.lang.reflect.ParameterizedType
        Returns:
        an array of Type objects representing the actual type arguments to this type
        Since:
        1.5
      • getRawType

        public java.lang.Class<?> getRawType()
        Returns the Type object representing the class or interface that declared this type.
        Specified by:
        getRawType in interface java.lang.reflect.ParameterizedType
        Returns:
        the Type object representing the class or interface that declared this type
      • getOwnerType

        public java.lang.reflect.Type getOwnerType()
        Returns a Type object representing the type that this type is a member of. For example, if this type is O.I, return a representation of O.

        If this type is a top-level type, null is returned.

        Specified by:
        getOwnerType in interface java.lang.reflect.ParameterizedType
        Returns:
        a Type object representing the type that this type is a member of. If this type is a top-level type, null is returned
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object