Package randoop.types
Class LazyParameterBound
- java.lang.Object
-
- randoop.types.ParameterBound
-
- randoop.types.LazyParameterBound
-
class LazyParameterBound extends ParameterBound
A lazy representation of a type bound in which a type variable occurs. Prevents type recognition from having to deal with recursive type bounds. All methods that need to evaluate the bound are provided with a substitution for the variable for which this object is a bound.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
LazyParameterBound.LazyBoundException
There was an attempt to perform an operation, such as capture conversion, on a lazy bound.
-
Constructor Summary
Constructors Constructor Description LazyParameterBound(Type boundType)
Creates aLazyParameterBound
from the given rawtype and type parameters.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ParameterBound
applyCaptureConversion()
Applies a capture conversion to any wildcard arguments in the type of this bound.boolean
equals(Object obj)
List<TypeVariable>
getTypeParameters()
Returns any type parameters in the type of this bound.private static List<TypeVariable>
getTypeParameters(Type type)
Collects the type parameters from the given reflectionType
object.boolean
hasCaptureVariable()
Indicates whether the type of this bound has a capture variable.private static boolean
hasCaptureVariable(Type type)
Return true if the given type has a capture variable.int
hashCode()
(package private) boolean
hasWildcard()
Indicates whether the type of this bound has a wildcard type argument.private static boolean
hasWildcard(Type type)
boolean
isGeneric(boolean ignoreWildcards)
Indicates whether the type of this bound is generic.boolean
isLowerBound(Type argType, Substitution substitution)
Indicates whether this bound is a lower bound of the given argument type.boolean
isObject()
Indicate whether this bound isObject
.boolean
isSubtypeOf(ParameterBound boundType)
Indicates whether the type of this bound is a subtype of the type of the given bound.(package private) boolean
isUpperBound(ParameterBound bound, Substitution substitution)
Indicates whether this bound is an upper bound on the type of the given bound with respect to the type substitution.boolean
isUpperBound(Type argType, Substitution substitution)
Determines if this bound is an upper bound for the argument type.boolean
isVariable()
Indicates whether this bound is a type variable.private static TypeArgument
substitute(Type type, Substitution substitution)
Applies a substitution to a reflection type that occurs as an actual argument of a parameterized type bound, to create a type argument to aParameterizedType
.ParameterBound
substitute(Substitution substitution)
Applies the given substitution to this type bound by replacing type variables.String
toString()
-
Methods inherited from class randoop.types.ParameterBound
forType, forType, forTypes, isGeneric, isLowerBound, isTypeVariable
-
-
-
-
Field Detail
-
boundType
private final Type boundType
The type for this bound.
-
-
Constructor Detail
-
LazyParameterBound
LazyParameterBound(Type boundType)
Creates aLazyParameterBound
from the given rawtype and type parameters.- Parameters:
boundType
- the reflection type for this bound
-
-
Method Detail
-
equals
public boolean equals(Object obj)
-
substitute
public ParameterBound substitute(Substitution substitution)
Description copied from class:ParameterBound
Applies the given substitution to this type bound by replacing type variables.- Specified by:
substitute
in classParameterBound
- Parameters:
substitution
- the type substitution- Returns:
- this bound with the type after the substitution has been applied
-
substitute
private static TypeArgument substitute(Type type, Substitution substitution)
Applies a substitution to a reflection type that occurs as an actual argument of a parameterized type bound, to create a type argument to aParameterizedType
.- Parameters:
type
- the reflection typesubstitution
- the type substitution- Returns:
- the type argument
-
applyCaptureConversion
public ParameterBound applyCaptureConversion()
Description copied from class:ParameterBound
Applies a capture conversion to any wildcard arguments in the type of this bound.- Specified by:
applyCaptureConversion
in classParameterBound
- Returns:
- this type with any wildcards replaced by capture conversion
- See Also:
ReferenceType.applyCaptureConversion()
-
getTypeParameters
public List<TypeVariable> getTypeParameters()
Description copied from class:ParameterBound
Returns any type parameters in the type of this bound.- Specified by:
getTypeParameters
in classParameterBound
- Returns:
- the list of
TypeVariable
objects in this bound
-
getTypeParameters
private static List<TypeVariable> getTypeParameters(Type type)
Collects the type parameters from the given reflectionType
object.- Parameters:
type
- theType
reference- Returns:
- the list of type variables in the given type
-
hasWildcard
boolean hasWildcard()
Description copied from class:ParameterBound
Indicates whether the type of this bound has a wildcard type argument.- Specified by:
hasWildcard
in classParameterBound
- Returns:
- true, if this bound has a wildcard argument, and false otherwise
-
hasWildcard
private static boolean hasWildcard(Type type)
-
hasCaptureVariable
public boolean hasCaptureVariable()
Description copied from class:ParameterBound
Indicates whether the type of this bound has a capture variable.- Specified by:
hasCaptureVariable
in classParameterBound
- Returns:
- true iff this bound has a capture variable
-
hasCaptureVariable
private static boolean hasCaptureVariable(Type type)
Return true if the given type has a capture variable.- Parameters:
type
- the type to test- Returns:
- true if the given type has a capture variable
-
isGeneric
public boolean isGeneric(boolean ignoreWildcards)
Description copied from class:ParameterBound
Indicates whether the type of this bound is generic.- Specified by:
isGeneric
in classParameterBound
- Parameters:
ignoreWildcards
- if true, ignore wildcards; that is, treat wildcards as not making the operation generic- Returns:
- true, if this bound type is generic, and false otherwise
-
isLowerBound
public boolean isLowerBound(Type argType, Substitution substitution)
Description copied from class:ParameterBound
Indicates whether this bound is a lower bound of the given argument type.- Specified by:
isLowerBound
in classParameterBound
- Parameters:
argType
- the concrete argument typesubstitution
- the substitution- Returns:
- true if this bound is a subtype of the given type
-
isObject
public boolean isObject()
Description copied from class:ParameterBound
Indicate whether this bound isObject
.- Specified by:
isObject
in classParameterBound
- Returns:
- true if this bound is
Object
, false otherwise
-
isSubtypeOf
public boolean isSubtypeOf(ParameterBound boundType)
Description copied from class:ParameterBound
Indicates whether the type of this bound is a subtype of the type of the given bound.- Specified by:
isSubtypeOf
in classParameterBound
- Parameters:
boundType
- the other bound- Returns:
- true if this type is a subtype of the other bound, false otherwise
-
isUpperBound
public boolean isUpperBound(Type argType, Substitution substitution)
Determines if this bound is an upper bound for the argument type.This generic type bound is satisfied by a concrete type if the concrete type formed by applying the substitution to this generic bound is satisfied by the concrete type.
- Specified by:
isUpperBound
in classParameterBound
- Parameters:
argType
- the concrete argument typesubstitution
- the substitution- Returns:
- true if this bound is satisfied by the concrete type when the substitution is used on the bound, false otherwise
-
isUpperBound
boolean isUpperBound(ParameterBound bound, Substitution substitution)
Description copied from class:ParameterBound
Indicates whether this bound is an upper bound on the type of the given bound with respect to the type substitution.- Specified by:
isUpperBound
in classParameterBound
- Parameters:
bound
- the other boundsubstitution
- the type substitution- Returns:
- true if this bound is an upper bound on the type of the given bound, false otherwise
-
isVariable
public boolean isVariable()
Description copied from class:ParameterBound
Indicates whether this bound is a type variable.- Overrides:
isVariable
in classParameterBound
- Returns:
- true if this bound is a type variable, false otherwise
-
-