Package randoop.types
Class IntersectionTypeBound
- java.lang.Object
-
- randoop.types.ParameterBound
-
- randoop.types.IntersectionTypeBound
-
class IntersectionTypeBound extends ParameterBound
Represents an intersection type bound on a type parameter in a class, interface, method or constructor (see JLS section 4.4). Alternatively, in capture conversion, it may also represent the greatest lower bound of two upper bounds ( JLS section 5.1.10).Java requires that an intersection type bound consist of class and interface types, with at most one class, and if there is a class it appears in the conjunction term first. This class preserves the order of the types. In a capture conversion, if both types are classes, one must be a subclass of the other.
-
-
Field Summary
Fields Modifier and Type Field Description private List<ParameterBound>
boundList
The list of type bounds for the intersection bound.
-
Constructor Summary
Constructors Constructor Description IntersectionTypeBound(List<ParameterBound> boundList)
Create an intersection type bound from the list of type bounds.
-
Method Summary
All 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.boolean
hasCaptureVariable()
Indicates whether the type of this bound has a capture variable.int
hashCode()
(package private) boolean
hasWildcard()
Indicates whether the type of this bound has a wildcard type argument.boolean
isGeneric(boolean ignoreWildcards)
Indicates whether the type of this bound is generic.boolean
isLowerBound(Type otherType, Substitution subst)
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 subst)
Determines if this bound is an upper bound for the argument type.IntersectionTypeBound
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, isVariable
-
-
-
-
Field Detail
-
boundList
private List<ParameterBound> boundList
The list of type bounds for the intersection bound.
-
-
Constructor Detail
-
IntersectionTypeBound
IntersectionTypeBound(List<ParameterBound> boundList)
Create an intersection type bound from the list of type bounds.- Parameters:
boundList
- the list of type bounds
-
-
Method Detail
-
substitute
public IntersectionTypeBound substitute(Substitution substitution)
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 substitution applied to all member bounds
-
applyCaptureConversion
public ParameterBound applyCaptureConversion()
Applies a capture conversion to any wildcard arguments in the type of this bound.- Specified by:
applyCaptureConversion
in classParameterBound
- Returns:
- an intersection bound with capture conversion applied to all member bounds
- See Also:
ReferenceType.applyCaptureConversion()
-
getTypeParameters
public List<TypeVariable> getTypeParameters()
Returns any type parameters in the type of this bound.- Specified by:
getTypeParameters
in classParameterBound
- Returns:
- the list of type variables occurring in all of the type bounds of this intersection bound
-
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
-
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
-
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 otherType, Substitution subst)
Indicates whether this bound is a lower bound of the given argument type.Specifically, this method checks that the argument type is a subtype of all of the member bounds of this object.
- Specified by:
isLowerBound
in classParameterBound
- Parameters:
otherType
- the concrete argument typesubst
- the substitution- Returns:
- true if this bound is a subtype of the given type
-
isObject
public boolean isObject()
Indicate whether this bound isObject
.Determines whether all types in this bound are
Object
.- Specified by:
isObject
in classParameterBound
- Returns:
- true if this bound is
Object
, false otherwise
-
isSubtypeOf
public boolean isSubtypeOf(ParameterBound boundType)
Indicates whether the type of this bound is a subtype of the type of the given bound.This method should never be tested for
IntersectionTypeBound
. Will fail if assertions are enabled.- Specified by:
isSubtypeOf
in classParameterBound
- Parameters:
boundType
- the other bound- Returns:
- false, always
-
isUpperBound
public boolean isUpperBound(Type argType, Substitution subst)
Determines if this bound is an upper bound for the argument type.- Specified by:
isUpperBound
in classParameterBound
- Parameters:
argType
- the concrete argument typesubst
- the substitution- Returns:
- true if the argument type satisfies all of the bounds in this intersection type bound
-
isUpperBound
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.- Specified by:
isUpperBound
in classParameterBound
- Parameters:
bound
- the other boundsubstitution
- the type substitution- Returns:
- true if the argument bound has all of the member bounds of this object as an upper bound
-
-