Class JavaWildcardType

  • All Implemented Interfaces:
    JavaType, HasName, HasUpperBounds

    public class JavaWildcardType
    extends java.lang.Object
    implements JavaType, HasUpperBounds
    Represents a wildcard type in a type signature (compare the JLS). Consider the generic type List<T>, then the parameterized type List<?> would have the wildcard ? as its type argument (also see JavaParameterizedType).
    According to the JLS a wildcard may have upper and lower bounds.
    An upper bound denotes a common supertype any substitution of this wildcard must be assignable to. It is denoted by ? extends SomeType.
    A lower bound denotes a common subtype that must be assignable to all substitutions of this wildcard type. It is denoted by ? super SomeType.
    • Method Detail

      • getUpperBounds

        @PublicAPI(usage=ACCESS)
        public java.util.List<JavaType> getUpperBounds()
        Specified by:
        getUpperBounds in interface HasUpperBounds
        Returns:
        All upper bounds of this JavaWildcardType, i.e. supertypes any substitution of this variable must extend. E.g. for List<? extends SomeClass> the upper bounds would be [SomeClass]
        Note that the JLS currently only allows a single upper bound for a wildcard type, but we follow the Reflection API here and support a collection (compare WildcardType.getUpperBounds()).
      • getLowerBounds

        @PublicAPI(usage=ACCESS)
        public java.util.List<JavaType> getLowerBounds()
        Returns:
        All lower bounds of this JavaWildcardType, i.e. any substitution for this JavaWildcardType must be a supertype of all lower bounds. E.g. for Handler<? super SomeClass>> the lower bounds would be [SomeClass].
        Note that the JLS currently only allows a single lower bound for a wildcard type, but we follow the Reflection API here and support a collection (compare WildcardType.getLowerBounds()).
      • toString

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