Package randoop.types

Class WildcardType

  • All Implemented Interfaces:
    Comparable<Type>

    class WildcardType
    extends ParameterType
    Represents a wildcard type, which occurs as a type argument to a parameterized type.

    A wildcard may have either an upper or lower bound as defined in JLS Section 4.5.1.

       ? [ extends ReferenceType ]
       ? [ super ReferenceType ]
     
    See Also:
    WildcardArgument
    • Field Detail

      • hasUpperBound

        private final boolean hasUpperBound
    • Constructor Detail

      • WildcardType

        private WildcardType()
      • WildcardType

        WildcardType​(ParameterBound bound,
                     boolean hasUpperBound)
    • Method Detail

      • forType

        public static WildcardType forType​(WildcardType type)
        Creates a wildcard type from a given reflection type. Assumes that the bounds array has a single element as defined in JLS Section 4.5.1.
        Parameters:
        type - the java.lang.reflect.WildcardType object
        Returns:
        a WildcardType with the bounds from the given reflection type
      • getFqName

        public String getFqName()
        Description copied from class: Type
        Returns the fully-qualified name of this type, including type arguments if this is a parameterized type. For java.util.List<T> return "java.util.List<T>".
        Specified by:
        getFqName in class Type
        Returns:
        the fully-qualified type name for this type
      • getBinaryName

        public String getBinaryName()
        Description copied from class: Type
        Returns the binary name of this type, including type arguments if this is a parameterized type (so, it isn't really a binary name). For java.util.List<T> return "java.util.List<T>".
        Specified by:
        getBinaryName in class Type
        Returns:
        the binary name for this type
      • getSimpleName

        public String getSimpleName()
        Description copied from class: Type
        Returns the name of this type without type arguments or package qualifiers. For java.util.List<T>, returns "List".
        Specified by:
        getSimpleName in class Type
        Returns:
        the name of this type without type arguments
      • getTypeBound

        public ParameterBound getTypeBound()
        Returns the bound of this -- either the upper or lower bound.
        Returns:
        the bound of this -- either the upper or lower bound
      • substitute

        public WildcardType substitute​(Substitution substitution)
        Description copied from class: ReferenceType
        Applies a substitution to a ReferenceType. If the type is parameterized then replaces type variables that occur, otherwise returns this type.

        This abstract method forces typing of substitutions applied to ReferenceType objects without an explicit cast.

        Specified by:
        substitute in class ReferenceType
        Parameters:
        substitution - the type substitution
        Returns:
        the type created by applying the substitution to this type
      • applyCaptureConversion

        public WildcardType applyCaptureConversion()
        Description copied from class: Type
        Applies a capture conversion to this type.
        Overrides:
        applyCaptureConversion in class ReferenceType
        Returns:
        a copy of this type with wildcards replaced by type conversion
      • contains

        public boolean contains​(WildcardType otherType)
        If this type has an upper bound, checks for containment cases:
        • ? extends T contains ? extends S if T.isSubtypeOf(S)
        • ? extends T contains ?
        Both of which are technically the same because from a reflection perspective ? is just ? extends Object. Otherwise, checks for the cases
        • ? super T contains ? super S if S.isSubtypeOf(T)
        • ? super T contains ?
        • ? super T contains ? extends Object
        The last two being equivalent from the perspective of reflection.
        Parameters:
        otherType - the type to check for
        Returns:
        true if this type contains the other type, false otherwise
      • isGeneric

        public boolean isGeneric​(boolean ignoreWildcards)
        Description copied from class: Type
        Indicate whether this type is generic. A type is generic if it has one or more type variables.
        Overrides:
        isGeneric in class Type
        Parameters:
        ignoreWildcards - if true, ignore wildcards; that is, treat wildcards as not making the operation generic
        Returns:
        true if this type is generic, false otherwise
      • hasUpperBound

        boolean hasUpperBound()