Class WildcardType


  • public class WildcardType
    extends AnnotatableType
    Type node for a wildcard type (added in JLS3 API).
     WildcardType:
        { Annotation } ? [ ( extends | super) Type ]
     

    Not all node arrangements will represent legal Java constructs. In particular, it is nonsense if a wildcard type node appears anywhere other than as an argument of a ParameterizedType node.

    Since:
    3.1
    Restriction:
    This class is not intended to be instantiated by clients.
    • Field Detail

      • ANNOTATIONS_PROPERTY

        public static final ChildListPropertyDescriptor ANNOTATIONS_PROPERTY
        The "annotations" structural property of this node type (element type: Annotation).
        Since:
        3.10
      • BOUND_PROPERTY

        public static final ChildPropertyDescriptor BOUND_PROPERTY
        The "bound" structural property of this node type (child type: Type).
      • UPPER_BOUND_PROPERTY

        public static final SimplePropertyDescriptor UPPER_BOUND_PROPERTY
        The "upperBound" structural property of this node type (type: Boolean).
    • Method Detail

      • propertyDescriptors

        public static List propertyDescriptors​(int apiLevel)
        Returns a list of structural property descriptors for this node type. Clients must not modify the result.
        Parameters:
        apiLevel - the API level; one of the AST.JLS* constants
        Returns:
        a list of property descriptors (element type: StructuralPropertyDescriptor)
      • isUpperBound

        public boolean isUpperBound()
        Returns whether this wildcard type is an upper bound ("extends") as opposed to a lower bound ("super").

        Note that this property is irrelevant for wildcards that do not have a bound.

        Returns:
        true if an upper bound, and false if a lower bound
        See Also:
        setBound(Type)
      • getBound

        public Type getBound()
        Returns the bound of this wildcard type if it has one. If isUpperBound returns true, this is an upper bound ("? extends B"); if it returns false, this is a lower bound ("? super B").
        Returns:
        the bound of this wildcard type, or null if none
        See Also:
        setBound(Type)
      • setBound

        public void setBound​(Type type,
                             boolean isUpperBound)
        Sets the bound of this wildcard type to the given type and marks it as an upper or a lower bound. The method is equivalent to calling setBound(type); setUpperBound(isUpperBound).
        Parameters:
        type - the new bound of this wildcard type, or null if none
        isUpperBound - true for an upper bound ("? extends B"), and false for a lower bound ("? super B")
        Throws:
        IllegalArgumentException - if:
        • the node belongs to a different AST
        • the node already has a parent
        See Also:
        getBound(), isUpperBound()
      • setBound

        public void setBound​(Type type)
        Sets the bound of this wildcard type to the given type.
        Parameters:
        type - the new bound of this wildcard type, or null if none
        Throws:
        IllegalArgumentException - if:
        • the node belongs to a different AST
        • the node already has a parent
        See Also:
        getBound()
      • setUpperBound

        public void setUpperBound​(boolean isUpperBound)
        Sets whether this wildcard type is an upper bound ("extends") as opposed to a lower bound ("super").
        Parameters:
        isUpperBound - true if an upper bound, and false if a lower bound
        See Also:
        isUpperBound()