Class ParameterizedType

java.lang.Object
org.jboss.jandex.Type
org.jboss.jandex.ParameterizedType

public class ParameterizedType extends Type
Represents a parameterized type. The name() corresponds to the raw type, and the arguments() list corresponds to the type arguments passed to the generic type in order to instantiate this parameterized type.

For example, the following declaration would have a name of java.util.Map and two ClassType arguments: java.lang.String and java.lang.Integer:

 Map<String, Integer>
 

Additionally, a parameterized type is used to represent an inner type whose enclosing type is either parameterized or has type annotations. In this case, the owner() method returns the type of the enclosing class. Such inner type may itself be parameterized.

For example, the following declaration shows the case where a parameterized type is used to represent a non-parameterized class X whose owner Y is parameterized:

 Y<String>.X
 
Author:
Jason T. Greene
Since:
2.0
  • Method Details

    • create

      public static ParameterizedType create(DotName name, Type[] arguments, Type owner)
      Create a new mock instance.
      Parameters:
      name - the name of this type
      arguments - an array of types representing arguments to this type
      owner - the enclosing type if annotated or parameterized, otherwise null
      Returns:
      the mock instance
      Since:
      2.1
    • arguments

      public List<Type> arguments()
      Returns the list of type arguments used to instantiate this parameterized type.
      Returns:
      the list of type arguments, or empty if none
    • owner

      public Type owner()
      Returns the owner (enclosing) type of this parameterized type, if the owner is parameterized or has type annotations. In the latter case, the owner may be a ClassType. Returns null otherwise.

      Note that parameterized inner classes whose enclosing types are not parameterized or type-annotated have no owner and hence this method returns null in such case.

      This example shows the case where a parameterized type is used to represent a non-parameterized class X:

       Y<String>.X
       
      This example will return a parameterized type for Y when X's owner() method is called.
      Returns:
      the owner type if the owner is parameterized or annotated, otherwise null
    • kind

      public Type.Kind kind()
      Description copied from class: Type
      Returns the kind of Type this is.
      Specified by:
      kind in class Type
      Returns:
      the kind
    • asParameterizedType

      public ParameterizedType asParameterizedType()
      Description copied from class: Type
      Casts this type to a ParameterizedType and returns it if the kind is Type.Kind.PARAMETERIZED_TYPE. Throws an exception otherwise.
      Overrides:
      asParameterizedType in class Type
      Returns:
      a ParameterizedType
    • equals

      public boolean equals(Object o)
      Description copied from class: Type
      Compares this Type with another type. A type is equal to another type if it is of the same kind, and all of their fields are equal. This includes annotations, which must be equal as well.
      Overrides:
      equals in class Type
      Parameters:
      o - the type to compare to
      Returns:
      true if equal
      See Also:
    • hashCode

      public int hashCode()
      Description copied from class: Type
      Computes a hash code representing this type.
      Overrides:
      hashCode in class Type
      Returns:
      the hash code
    • internEquals

      public boolean internEquals(Object o)
      Overrides:
      internEquals in class Type
    • internHashCode

      public int internHashCode()
      Overrides:
      internHashCode in class Type