Package randoop.types
Class TypeArgument
- java.lang.Object
-
- randoop.types.TypeArgument
-
- Direct Known Subclasses:
ReferenceArgument
,WildcardArgument
public abstract class TypeArgument extends Object
Represents a type argument of a parameterized type as described in JLS Section 4.5.1.TypeArgument: ReferenceType Wildcard
- See Also:
ReferenceArgument
,WildcardArgument
-
-
Constructor Summary
Constructors Constructor Description TypeArgument()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract boolean
contains(TypeArgument otherArgument)
Checks whether this type argument contains another argument, using relationship defined in JLS Section 4.5.1.static TypeArgument
forType(Type type)
Converts ajava.lang.reflect.Type
to aTypeArgument
object.static TypeArgument
forType(ReferenceType referenceType)
abstract String
getBinaryName()
Return the binary name.abstract String
getFqName()
Return the fully-qualified name.Substitution
getInstantiatingSubstitution(TypeArgument goalType)
Returns a unifying substitution.List<TypeVariable>
getTypeParameters()
The type parameters for this type argument.boolean
hasCaptureVariable()
Indicate whether this type argument has a capture variable.boolean
hasWildcard()
Indicate whether this type argument has a wildcard.boolean
isGeneric()
Indicates whether this type argument is generic.abstract 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.abstract boolean
isVariable()
Indicate whether this type argument is a type variable.boolean
isWildcard()
Indicate whether this type argument is a wildcard argument.abstract TypeArgument
substitute(Substitution substitution)
Applies the type substitution to this type argument.
-
-
-
Method Detail
-
forType
public static TypeArgument forType(Type type)
Converts ajava.lang.reflect.Type
to aTypeArgument
object.- Parameters:
type
- the type of a type argument- Returns:
- the
TypeArgument
for the given type
-
forType
public static TypeArgument forType(ReferenceType referenceType)
-
substitute
public abstract TypeArgument substitute(Substitution substitution)
Applies the type substitution to this type argument.- Parameters:
substitution
- the substitution- Returns:
- a version of this type argument with type variables replaced by the substitution
-
contains
public abstract boolean contains(TypeArgument otherArgument)
Checks whether this type argument contains another argument, using relationship defined in JLS Section 4.5.1.- Parameters:
otherArgument
- the otherTypeArgument
- Returns:
- true if this argument contains the other argument
-
getTypeParameters
public List<TypeVariable> getTypeParameters()
The type parameters for this type argument.- Returns:
- the list of type parameters for this argument
-
hasWildcard
public boolean hasWildcard()
Indicate whether this type argument has a wildcard.- Returns:
- true if this argument has a wildcard argument
-
hasCaptureVariable
public boolean hasCaptureVariable()
Indicate whether this type argument has a capture variable.- Returns:
- true if this argument has a capture variable
-
isGeneric
public final boolean isGeneric()
Indicates whether this type argument is generic.- Returns:
- true if this type argument is generic, false otherwise
-
isGeneric
public abstract boolean isGeneric(boolean ignoreWildcards)
Indicates whether this type argument is generic.- 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)
Determines whether this type argument is an instantiation of the other argument.- Parameters:
otherArgument
- the other argument- Returns:
- true if this type is an instantiation of the other argument, false otherwise
- See Also:
InstantiatedType.isInstantiationOf(ReferenceType)
-
isWildcard
public boolean isWildcard()
Indicate whether this type argument is a wildcard argument.- Returns:
- true if this is a wildcard argument, false otherwise
-
getInstantiatingSubstitution
public Substitution getInstantiatingSubstitution(TypeArgument goalType)
Returns a unifying substitution. Returns null if unification failed.- 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
-
isVariable
public abstract boolean isVariable()
Indicate whether this type argument is a type variable.- Returns:
- true if this argument is a type variable, false otherwise
-
getFqName
public abstract String getFqName()
Return the fully-qualified name.- Returns:
- the fully-qualified name
-
getBinaryName
public abstract String getBinaryName()
Return the binary name.- Returns:
- the binary name
-
-