Package randoop.types

Class WildcardArgument


  • public class WildcardArgument
    extends TypeArgument
    Represents a wildcard type argument to a parameterized type.

    The subclasses represent the type bound as given for the wildcard.

    • Field Detail

      • argumentType

        private final WildcardType argumentType
        The wildcard type.
    • Constructor Detail

      • WildcardArgument

        WildcardArgument​(WildcardType argumentType)
        Initializes the bound type.
        Parameters:
        argumentType - the wildcard type
    • Method Detail

      • forType

        public static WildcardArgument forType​(Type type)
        Creates a WildcardArgument from a java.lang.reflect.Type. A wildcard may have either an upper or lower bound.
        Parameters:
        type - the Type object
        Returns:
        the WildcardArgument created from the given Type
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • getFqName

        public String getFqName()
        Description copied from class: TypeArgument
        Return the fully-qualified name.
        Specified by:
        getFqName in class TypeArgument
        Returns:
        the fully-qualified name
      • substitute

        public WildcardArgument substitute​(Substitution substitution)
        Description copied from class: TypeArgument
        Applies the type substitution to this type argument.
        Specified by:
        substitute in class TypeArgument
        Parameters:
        substitution - the substitution
        Returns:
        a version of this type argument with type variables replaced by the substitution
      • contains

        public boolean contains​(TypeArgument argument)
        Description copied from class: TypeArgument
        Checks whether this type argument contains another argument, using relationship defined in JLS Section 4.5.1.
        Specified by:
        contains in class TypeArgument
        Parameters:
        argument - the other TypeArgument
        Returns:
        true if this argument contains the other argument
      • getTypeBound

        public ParameterBound getTypeBound()
        Return the type of the upper/lower bound of this wildcard argument.
        Returns:
        the type of the bound of this wildcard argument
      • getTypeParameters

        public List<TypeVariable> getTypeParameters()
        The type parameters for this type argument.

        Returns the type parameters of the bound of this wildcard argument

        Overrides:
        getTypeParameters in class TypeArgument
        Returns:
        the list of type parameters for this argument
      • hasUpperBound

        boolean hasUpperBound()
        Indicates whether this wildcard argument has an upper bound. (If not, then it has a lower bound.)
        Returns:
        true if this wildcard argument has an upper bound, false if it has a lower bound
      • hasWildcard

        public boolean hasWildcard()
        Description copied from class: TypeArgument
        Indicate whether this type argument has a wildcard.
        Overrides:
        hasWildcard in class TypeArgument
        Returns:
        true if this argument has a wildcard argument
      • hasCaptureVariable

        public boolean hasCaptureVariable()
        Description copied from class: TypeArgument
        Indicate whether this type argument has a capture variable.
        Overrides:
        hasCaptureVariable in class TypeArgument
        Returns:
        true if this argument has a capture variable
      • isGeneric

        public boolean isGeneric​(boolean ignoreWildcards)
        Description copied from class: TypeArgument
        Indicates whether this type argument is generic.
        Specified by:
        isGeneric in class TypeArgument
        Parameters:
        ignoreWildcards - if true, ignore wildcards; that is, treat wildcards as not making the operation generic
        Returns:
        true if this type argument is generic, false otherwise
      • getInstantiatingSubstitution

        public Substitution getInstantiatingSubstitution​(TypeArgument goalType)
        Description copied from class: TypeArgument
        Returns a unifying substitution. Returns null if unification failed.
        Overrides:
        getInstantiatingSubstitution in class TypeArgument
        Parameters:
        goalType - the generic type for which a substitution is needed
        Returns:
        a substitution unifying this type or a supertype of this type with the goal type, or null if unification failed
      • isWildcard

        public boolean isWildcard()
        Description copied from class: TypeArgument
        Indicate whether this type argument is a wildcard argument.
        Overrides:
        isWildcard in class TypeArgument
        Returns:
        true if this is a wildcard argument, false otherwise
      • isVariable

        public boolean isVariable()
        Description copied from class: TypeArgument
        Indicate whether this type argument is a type variable.
        Specified by:
        isVariable in class TypeArgument
        Returns:
        true if this argument is a type variable, false otherwise