Class WildcardType

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

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".
Author:
Jason T. Greene
Since:
2.0
  • Method Details

    • create

      public static WildcardType create(Type bound, boolean isExtends)
      Create a new mock instance of WildcardType.
      Parameters:
      bound - the bound (lower or upper)
      isExtends - true if lower, false if upper (super)
      Returns:
      thew new mock instance
      Since:
      2.1
    • name

      public DotName name()
      Description copied from class: Type
      Returns the raw name of this type. Primitives and void are returned as the Java keyword (void, boolean, byte, short, int, long, float, double, char). Arrays are returned using the Java reflection array syntax (e.g. [[[Ljava.lang.String;) Classes are returned as a normal DotName.

      Generic values are returned as the underlying raw value. For example, a wildcard such as ? extends Number has a raw type of Number.

      Overrides:
      name in class Type
      Returns:
      the name of this type
    • 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 uper bound
    • 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
    • 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