Package randoop.types
Class ReferenceArgument
- java.lang.Object
-
- randoop.types.TypeArgument
-
- randoop.types.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 Summary
Fields Modifier and Type Field Description private ReferenceType
referenceType
The reference type for this argument.
-
Constructor Summary
Constructors Modifier Constructor Description private
ReferenceArgument(ReferenceType referenceType)
Creates aReferenceArgument
for the givenReferenceType
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
contains(TypeArgument otherArgument)
Checks whether this type argument contains another argument, using relationship defined in JLS Section 4.5.1.boolean
equals(Object obj)
static ReferenceArgument
forType(Type type)
Creates aReferenceArgument
from the given type.static ReferenceArgument
forType(ReferenceType referenceType)
String
getBinaryName()
Return the binary name.String
getFqName()
Return the fully-qualified name.Substitution
getInstantiatingSubstitution(TypeArgument otherArgument)
Returns a unifying substitution.ReferenceType
getReferenceType()
Get the reference type for this type argument.List<TypeVariable>
getTypeParameters()
The type parameters for this type argument.boolean
hasCaptureVariable()
Indicate whether this type argument has a capture variable.int
hashCode()
boolean
hasWildcard()
Indicate whether this type argument has a wildcard.boolean
isGeneric(boolean ignoreWildcards)
Indicates whether aReferenceArgument
is generic.(package private) boolean
isInstantiationOfTypeArgument(TypeArgument otherArgument)
Determines whether this type argument is an instantiation of the other argument.boolean
isVariable()
Indicate whether this type argument is a type variable.TypeArgument
substitute(Substitution substitution)
Applies the type substitution to this type argument.String
toString()
-
Methods inherited from class randoop.types.TypeArgument
isGeneric, isWildcard
-
-
-
-
Field Detail
-
referenceType
private final ReferenceType referenceType
The reference type for this argument.
-
-
Constructor Detail
-
ReferenceArgument
private ReferenceArgument(ReferenceType referenceType)
Creates aReferenceArgument
for the givenReferenceType
.- Parameters:
referenceType
- theReferenceType
-
-
Method Detail
-
forType
public static ReferenceArgument forType(Type type)
Creates aReferenceArgument
from the given type.- Parameters:
type
- the type- Returns:
- a
ReferenceArgument
for the given type
-
forType
public static ReferenceArgument forType(ReferenceType referenceType)
-
getFqName
public String getFqName()
Description copied from class:TypeArgument
Return the fully-qualified name.- Specified by:
getFqName
in classTypeArgument
- Returns:
- the fully-qualified name
-
getBinaryName
public String getBinaryName()
Description copied from class:TypeArgument
Return the binary name.- Specified by:
getBinaryName
in classTypeArgument
- Returns:
- the binary name
-
substitute
public TypeArgument substitute(Substitution substitution)
Description copied from class:TypeArgument
Applies the type substitution to this type argument.- Specified by:
substitute
in classTypeArgument
- 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
containsT
T
contains? extends T
T
contains? super T
- Specified by:
contains
in classTypeArgument
- Parameters:
otherArgument
- the otherTypeArgument
- 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
-
getTypeParameters
public List<TypeVariable> getTypeParameters()
Description copied from class:TypeArgument
The type parameters for this type argument.- Overrides:
getTypeParameters
in classTypeArgument
- Returns:
- the list of type parameters for this argument
-
hasWildcard
public boolean hasWildcard()
Description copied from class:TypeArgument
Indicate whether this type argument has a wildcard.- Overrides:
hasWildcard
in classTypeArgument
- 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 classTypeArgument
- Returns:
- true if this argument has a capture variable
-
isGeneric
public boolean isGeneric(boolean ignoreWildcards)
Indicates whether aReferenceArgument
is generic.- Specified by:
isGeneric
in classTypeArgument
- 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
-
isInstantiationOfTypeArgument
boolean isInstantiationOfTypeArgument(TypeArgument otherArgument)
Description copied from class:TypeArgument
Determines whether this type argument is an instantiation of the other argument.- Overrides:
isInstantiationOfTypeArgument
in classTypeArgument
- Parameters:
otherArgument
- the other argument- Returns:
- true if this type is an instantiation of the other argument, false otherwise
- See Also:
InstantiatedType.isInstantiationOf(ReferenceType)
-
getInstantiatingSubstitution
public Substitution getInstantiatingSubstitution(TypeArgument otherArgument)
Description copied from class:TypeArgument
Returns a unifying substitution. Returns null if unification failed.- Overrides:
getInstantiatingSubstitution
in classTypeArgument
- 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 classTypeArgument
- Returns:
- true if this argument is a type variable, false otherwise
-
-