Package randoop.types

Class ReferenceArgument


  • public class ReferenceArgument
    extends TypeArgument
    Represents a reference type as a type argument to a parameterized type. (See JLS Section 4.5.1.)
    • Field Detail

      • referenceType

        private final ReferenceType referenceType
        The reference type for this argument.
    • Method Detail

      • forType

        public static ReferenceArgument forType​(Type type)
        Creates a ReferenceArgument from the given type.
        Parameters:
        type - the type
        Returns:
        a ReferenceArgument for 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 TypeArgument 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 otherArgument)
        Checks whether this type argument contains another argument, using relationship defined in JLS Section 4.5.1.

        Considers cases:

        • T contains T
        • T contains ? extends T
        • T contains ? super T
        Specified by:
        contains in class TypeArgument
        Parameters:
        otherArgument - the other TypeArgument
        Returns:
        true if this argument contains the other argument
      • getReferenceType

        public ReferenceType getReferenceType()
        Get the reference type for this type argument.
        Returns:
        the reference type of this type argument
      • 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)
        Indicates whether a ReferenceArgument 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 the ReferenceType is generic, false otherwise
      • getInstantiatingSubstitution

        public Substitution getInstantiatingSubstitution​(TypeArgument otherArgument)
        Description copied from class: TypeArgument
        Returns a unifying substitution. Returns null if unification failed.
        Overrides:
        getInstantiatingSubstitution in class TypeArgument
        Parameters:
        otherArgument - 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
      • 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