Class WildcardType

java.lang.Object
org.jboss.jandex.Type
org.jboss.jandex.WildcardType
All Implemented Interfaces:
Descriptor

public class WildcardType extends Type
Represents a generic wildcard. A generic wildcard can have either an upper (extends) or a lower (super) bound. A wildcard declared without a bound ("?") has a default extends bound of "java.lang.Object".
Since:
2.0
  • Field Details

    • UNBOUNDED

      public static final WildcardType UNBOUNDED
      A wildcard without a bound, an equivalent of ?.
      Since:
      3.1.0
    • isExtends

      private final boolean isExtends
    • bound

      private final Type bound
    • hash

      private int hash
  • Constructor Details

    • WildcardType

      WildcardType(Type bound, boolean isExtends)
    • WildcardType

      WildcardType(Type bound, boolean isExtends, AnnotationInstance[] annotations)
  • Method Details

    • create

      @Deprecated public static WildcardType create(Type bound, boolean isExtends)
      Creates a new wildcard type.
      Parameters:
      bound - the bound (lower or upper)
      isExtends - true if the bound is an upper (extends) bound, false if lower (super)
      Returns:
      the new instance
      Since:
      2.1
    • createUpperBound

      public static WildcardType createUpperBound(Type upperBound)
      Create a new wildcard type with an upper (extends) bound.
      Parameters:
      upperBound - the upper bound
      Returns:
      the new instance
      Since:
      3.1.0
    • createUpperBound

      public static WildcardType createUpperBound(Class<?> upperBound)
      Create a new wildcard type with an upper (extends) bound.
      Parameters:
      upperBound - the upper bound
      Returns:
      the new instance
      Since:
      3.1.0
    • createLowerBound

      public static WildcardType createLowerBound(Type lowerBound)
      Create a new wildcard type with a lower (super) bound.
      Parameters:
      lowerBound - the lower bound
      Returns:
      the new instance
      Since:
      3.1.0
    • createLowerBound

      public static WildcardType createLowerBound(Class<?> lowerBound)
      Create a new wildcard type with a lower (super) bound.
      Parameters:
      lowerBound - the lower bound
      Returns:
      the new instance
      Since:
      3.1.0
    • builder

      public static WildcardType.Builder builder()
      Create a builder of a wildcard type.
      Returns:
      the builder
      Since:
      3.1.0
    • name

      public DotName name()
      Description copied from class: Type
      Returns the name of this type (or its erasure in case of generic types) as a DotName, using the Class.getName() format. Specifically:
      • for primitive types and the void pseudo-type, the corresponding Java keyword is returned (void, boolean, byte, short, int, long, float, double, char);
      • for class types, the binary name of the class is returned;
      • for array types, a string is returned that consists of one or more [ characters corresponding to the number of dimensions of the array type, followed by the element type as a single-character code for primitive types or Lbinary.name.of.TheClass; for class types (for example, [I for int[] or [[Ljava.lang.String; for String[][]);
      • for parameterized types, the binary name of the generic class is returned (for example, java.util.List for List<String>);
      • for type variables, the name of the first bound of the type variable is returned, or java.lang.Object for type variables that have no bound;
      • for wildcard types, the name of the upper bound is returned, or java.lang.Object if the wildcard type does not have an upper bound (for example, java.lang.Number for ? extends Number).
      Overrides:
      name in class Type
      Returns:
      the name of this type (or its erasure in case of generic types)
    • extendsBound

      public Type extendsBound()
      Returns the upper bound of this wildcard (e.g. SomeType for ? extends SomeType).

      Returns java.lang.Object if this wildcard declares a lower bound (? super SomeType).

      Returns:
      the upper bound, or Object if this wildcard has a lower bound
    • superBound

      public Type superBound()
      Returns the lower bound of this wildcard (e.g. SomeType for ? super SomeType).

      Returns null if this wildcard declares an upper bound (? extends SomeType).

      Returns:
      the lower bound, or null if this wildcard has an upper bound
    • bound

      Type bound()
    • isExtends

      boolean isExtends()
    • hasImplicitObjectBound

      boolean hasImplicitObjectBound()
    • 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
    • asWildcardType

      public WildcardType asWildcardType()
      Description copied from class: Type
      Casts this type to a WildcardType and returns it if the kind is Type.Kind.WILDCARD_TYPE. Throws an exception otherwise.
      Overrides:
      asWildcardType in class Type
      Returns:
      a WildcardType
    • copyType

      Type copyType(AnnotationInstance[] newAnnotations)
      Specified by:
      copyType in class Type
    • withoutAnnotations

      Type withoutAnnotations()
      Description copied from class: Type
      Returns this type with all type annotations removed. The annotations are removed deeply, that is also on the constituent type in case of arrays, on type arguments in case of parameterized types, on the bound in case of wildcard types, etc.
      Overrides:
      withoutAnnotations in class Type
      Returns:
      this type without type annotations
    • copyType

      Type copyType(Type bound)
    • toString

      String toString(boolean simple)
      Overrides:
      toString in class Type
    • 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

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

      int internHashCode()
      Overrides:
      internHashCode in class Type