public abstract class ParameterBound
extends java.lang.Object
Type bounds for explicitly defined type variables of generic declarations are defined in JLS section 8.1.2 as
TypeBound: extends TypeVariable extends ClassOrInterfaceType [ & InterfaceType ]Type bounds for wildcards may be any reference type, which includes type variables, so the
ParameterBound
class hierarchy is simplified to use this ReferenceType
objects as
bounds. Intersection types (which includes the greatest lower bound construction used in capture
conversion) are explicitly represented. And, recursive type bounds are avoided by holding any
java.lang.reflect.Type
with variables as a LazyParameterBound
.
Type parameters only have upper bounds, but variables introduced by capture conversion can
have lower bounds. This class and its subclasses can represent both, with the default lower bound
being JavaTypes.NULL_TYPE
, and the default upperbound being JavaTypes.OBJECT_TYPE
.
Constructor and Description |
---|
ParameterBound() |
Modifier and Type | Method and Description |
---|---|
abstract ParameterBound |
applyCaptureConversion()
Applies a capture conversion to any wildcard arguments in the type of this bound.
|
static ParameterBound |
forType(ReferenceType type)
Constructs a parameter bound given a
ReferenceType . |
(package private) static ParameterBound |
forType(java.util.Set<java.lang.reflect.TypeVariable<?>> variableSet,
java.lang.reflect.Type type)
Creates a
ParameterBound object from a single java.lang.reflect.Type . |
(package private) static ParameterBound |
forTypes(java.util.Set<java.lang.reflect.TypeVariable<?>> variableSet,
java.lang.reflect.Type[] bounds)
Creates a bound from the array of bounds of a
java.lang.reflect.TypeVariable . |
abstract java.util.List<TypeVariable> |
getTypeParameters()
Returns any type parameters in the type of this bound.
|
(package private) abstract boolean |
hasCaptureVariable()
Indicates whether the type of this bound has a capture variable.
|
private static boolean |
hasTypeVariable(java.lang.reflect.Type type,
java.util.Set<java.lang.reflect.TypeVariable<?>> variableSet)
Indicates whether the given (reflection) type reference represents a type in which a type
variable occurs.
|
(package private) abstract boolean |
hasWildcard()
Indicates whether the type of this bound has a wildcard type argument.
|
(package private) boolean |
isGeneric()
Indicates whether the type of this bound is generic.
|
abstract boolean |
isGeneric(boolean ignoreWildcards)
Indicates whether the type of this bound is generic.
|
(package private) boolean |
isLowerBound(ParameterBound bound,
Substitution substitution)
Tests whether this is a lower bound on the type of a given bound with respect to a type
substitution.
|
abstract boolean |
isLowerBound(Type argType,
Substitution subst)
Indicates whether this bound is a lower bound of the given argument type.
|
abstract boolean |
isObject()
Indicate whether this bound is
Object . |
abstract boolean |
isSubtypeOf(ParameterBound boundType)
Indicates whether the type of this bound is a subtype of the type of the given bound.
|
(package private) static boolean |
isTypeVariable(java.lang.reflect.Type type)
Indicates whether the type is a type variable.
|
(package private) abstract 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.
|
abstract boolean |
isUpperBound(Type argType,
Substitution subst)
Determines if this bound is an upper bound for the argument type.
|
boolean |
isVariable()
Indicates whether this bound is a type variable.
|
abstract ParameterBound |
substitute(Substitution substitution)
Applies the given substitution to this type bound by replacing type variables.
|
public static ParameterBound forType(ReferenceType type)
ReferenceType
.type
- the ReferenceType
EagerReferenceBound
with the given typestatic ParameterBound forTypes(java.util.Set<java.lang.reflect.TypeVariable<?>> variableSet, java.lang.reflect.Type[] bounds)
java.lang.reflect.TypeVariable
.
The bounds of a type parameter are restricted, but those of a wildcard may be any reference type. See JLS section 8.1.2.
variableSet
- the set of variables affected by this boundbounds
- the type boundsParameterBound
for the given typesstatic ParameterBound forType(java.util.Set<java.lang.reflect.TypeVariable<?>> variableSet, java.lang.reflect.Type type)
ParameterBound
object from a single java.lang.reflect.Type
. Tests for
types that are represented by Class
objects, or java.lang.reflect.ParameterizedType
objects.variableSet
- the set of type variables bound by this typetype
- the type for type boundpublic abstract ParameterBound substitute(Substitution substitution)
substitution
- the type substitutionpublic abstract ParameterBound applyCaptureConversion()
ReferenceType.applyCaptureConversion()
public abstract java.util.List<TypeVariable> getTypeParameters()
TypeVariable
objects in this boundprivate static boolean hasTypeVariable(java.lang.reflect.Type type, java.util.Set<java.lang.reflect.TypeVariable<?>> variableSet)
type
- the reflection typevariableSet
- the set of variablesstatic boolean isTypeVariable(java.lang.reflect.Type type)
type
- the type to testabstract boolean hasWildcard()
abstract boolean hasCaptureVariable()
final boolean isGeneric()
public abstract boolean isGeneric(boolean ignoreWildcards)
ignoreWildcards
- if true, ignore wildcards; that is, treat wildcards as not making the
operation genericpublic abstract boolean isLowerBound(Type argType, Substitution subst)
argType
- the concrete argument typesubst
- the substitutionboolean isLowerBound(ParameterBound bound, Substitution substitution)
return this.substitute(substitution).isLowerBound(bound.substitute(substitution);
bound
- the other boundsubstitution
- the type substitutionpublic abstract boolean isObject()
Object
.Object
, false otherwisepublic abstract boolean isSubtypeOf(ParameterBound boundType)
boundType
- the other boundpublic abstract boolean isUpperBound(Type argType, Substitution subst)
argType
- the concrete argument typesubst
- the substitutionabstract boolean isUpperBound(ParameterBound bound, Substitution substitution)
bound
- the other boundsubstitution
- the type substitutionpublic boolean isVariable()