Package randoop.types
Class WildcardArgument
- java.lang.Object
-
- randoop.types.TypeArgument
-
- randoop.types.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 Summary
Fields Modifier and Type Field Description private WildcardType
argumentType
The wildcard type.
-
Constructor Summary
Constructors Constructor Description WildcardArgument(WildcardType argumentType)
Initializes the bound type.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description WildcardArgument
applyCaptureConversion()
Applies a capture conversion to the bound of thisWildcardArgument
.boolean
contains(TypeArgument argument)
Checks whether this type argument contains another argument, using relationship defined in JLS Section 4.5.1.boolean
equals(Object obj)
static WildcardArgument
forType(Type type)
Creates aWildcardArgument
from ajava.lang.reflect.Type
.static WildcardArgument
forType(ReferenceType argumentType)
String
getBinaryName()
Return the binary name.String
getFqName()
Return the fully-qualified name.Substitution
getInstantiatingSubstitution(TypeArgument goalType)
Returns a unifying substitution.ParameterBound
getTypeBound()
Return the type of the upper/lower bound of this wildcard argument.List<TypeVariable>
getTypeParameters()
The type parameters for this type argument.(package private) WildcardType
getWildcardType()
boolean
hasCaptureVariable()
Indicate whether this type argument has a capture variable.int
hashCode()
(package private) boolean
hasUpperBound()
Indicates whether this wildcard argument has an upper bound.boolean
hasWildcard()
Indicate whether this type argument has a wildcard.boolean
isGeneric(boolean ignoreWildcards)
Indicates whether this type argument 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.boolean
isWildcard()
Indicate whether this type argument is a wildcard argument.WildcardArgument
substitute(Substitution substitution)
Applies the type substitution to this type argument.String
toString()
-
Methods inherited from class randoop.types.TypeArgument
isGeneric
-
-
-
-
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 aWildcardArgument
from ajava.lang.reflect.Type
. A wildcard may have either an upper or lower bound.- Parameters:
type
- theType
object- Returns:
- the
WildcardArgument
created from the givenType
-
forType
public static WildcardArgument forType(ReferenceType argumentType)
-
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 WildcardArgument 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
-
applyCaptureConversion
public WildcardArgument applyCaptureConversion()
Applies a capture conversion to the bound of thisWildcardArgument
.- Returns:
- this wildcard argument with capture conversion applied to the type bound
- See Also:
ReferenceType.applyCaptureConversion()
-
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 classTypeArgument
- Parameters:
argument
- the otherTypeArgument
- 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 classTypeArgument
- 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 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)
Description copied from class:TypeArgument
Indicates whether this type argument 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 this type argument 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 goalType)
Description copied from class:TypeArgument
Returns a unifying substitution. Returns null if unification failed.- Overrides:
getInstantiatingSubstitution
in classTypeArgument
- 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 classTypeArgument
- 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 classTypeArgument
- Returns:
- true if this argument is a type variable, false otherwise
-
getWildcardType
WildcardType getWildcardType()
-
-