class CaptureTypeVariable extends TypeVariable
A CaptureTypeVariable
has both an upper and lower bound determined by combining the
wildcard bound with the ParameterBound
on the type parameter. An object is constructed
from a wildcard using the wildcard bound to determine the initial upper or lower bound. The
convert(TypeVariable, Substitution)
method is then used to update the bounds to match
the definition in JLS section 5.1.10, Capture
Conversion.
Modifier and Type | Field and Description |
---|---|
private static int |
count
The ID counter for capture conversion variables.
|
private int |
varID
The integer ID of this capture variable.
|
private WildcardArgument |
wildcard
The wildcard.
|
Modifier | Constructor and Description |
---|---|
private |
CaptureTypeVariable(int varID,
WildcardArgument wildcard,
ParameterBound lowerBound,
ParameterBound upperBound)
Creates a
CaptureTypeVariable with explicitly given ID , wildcard, and bounds. |
(package private) |
CaptureTypeVariable(WildcardArgument wildcard)
Creates a
CaptureTypeVariable for the given wildcard. |
Modifier and Type | Method and Description |
---|---|
void |
convert(TypeVariable typeParameter,
Substitution substitution)
Converts the bounds on this
CaptureTypeVariable by including those of the formal type
parameters of the generic type, and applying the implied substitution between the type
parameters and capture conversion argument list. |
TypeVariable |
createCopyWithBounds(ParameterBound lowerBound,
ParameterBound upperBound) |
boolean |
equals(@Nullable java.lang.Object obj) |
java.lang.String |
getBinaryName()
Returns the binary name of this type, including type arguments if this is a parameterized type
(so, it isn't really a binary name).
|
java.lang.String |
getFqName()
Returns the fully-qualified name of this type, including type arguments if this is a
parameterized type.
|
java.lang.String |
getSimpleName()
Returns the name of this type without type arguments or package qualifiers.
|
(package private) WildcardArgument |
getWildcard()
Returns the wildcard.
|
boolean |
hasCaptureVariable()
Indicates whether this
ReferenceType has a capture variable. |
int |
hashCode() |
boolean |
isCaptureVariable()
Indicates whether this type is a capture type variable as constructed by
InstantiatedType.applyCaptureConversion() . |
boolean |
isGeneric(boolean ignoreWildcards)
Indicate whether this type is generic.
|
ReferenceType |
substitute(Substitution substitution)
Applies a substitution to a
ReferenceType . |
java.lang.String |
toString() |
canBeInstantiatedBy, forType, getRawtype, getTypeParameters, isAssignableFrom, isInstantiationOf, isSubtypeOf, isVariable
getCanonicalName, getLowerTypeBound, getRuntimeClass, getUpperTypeBound, hasGenericBound, hasWildcard, setLowerBound, setUpperBound
applyCaptureConversion, forClass, getInstantiatingSubstitution, getInstantiatingSubstitutionforTypeVariable, isReferenceType
compareTo, forFullyQualifiedName, forName, forValue, getTypeforFullyQualifiedName, getUnqualifiedBinaryName, isArray, isAssignableFromTypeOf, isBoxedPrimitive, isClass, isClassOrInterfaceType, isEnum, isGeneric, isInterface, isNonreceiverType, isObject, isParameterized, isPrimitive, isRawtype, isString, isVoid, runtimeClassIs
private static int count
private final int varID
private final WildcardArgument wildcard
CaptureTypeVariable(WildcardArgument wildcard)
CaptureTypeVariable
for the given wildcard. Created object is not complete
until convert(TypeVariable, Substitution)
is run.wildcard
- the wildcard argumentprivate CaptureTypeVariable(int varID, WildcardArgument wildcard, ParameterBound lowerBound, ParameterBound upperBound)
CaptureTypeVariable
with explicitly given ID
, wildcard, and bounds.varID
- the variable ID for the created variablewildcard
- the wildcard for the created variablelowerBound
- the lower type bound of the variableupperBound
- the upper type bound of the variableWildcardArgument getWildcard()
public boolean equals(@Nullable java.lang.Object obj)
equals
in class ParameterType
public int hashCode()
hashCode
in class ParameterType
public java.lang.String toString()
toString
in class TypeVariable
public void convert(TypeVariable typeParameter, Substitution substitution)
CaptureTypeVariable
by including those of the formal type
parameters of the generic type, and applying the implied substitution between the type
parameters and capture conversion argument list. Implements the clauses of the JLS section
5.1.10, Capture
Conversion.
Creates an upper bound on a type variable resulting from a capture conversion (JLS section
5.1.10) in the case that a wildcard has an upper bound other than Object. In particular, each
object represents a bound on a variable Si
in a parameterized type C<S1,...,Sn>
defined as glb(Bi, Ui[Ai:=Si])
where
Ui
is the upper bound on the type variable Ai
in the declared class
C<A1,...,An>
,
glb(S, T)
for types S
and T
is the intersection type S &
T
.
S
and T
are both class types not related as subtypes,
then the greatest lower bound of the two types is a compiler error. Technically it is the null
type.typeParameter
- the formal type parameter of the generic typesubstitution
- the capture conversion substitutionpublic java.lang.String getFqName()
Type
java.util.List<T>
return "java.util.List<T>"
.public java.lang.String getBinaryName()
Type
java.util.List<T>
return "java.util.List<T>"
.getBinaryName
in class Type
public java.lang.String getSimpleName()
Type
java.util.List<T>
, returns "List"
.getSimpleName
in class Type
public boolean isCaptureVariable()
ReferenceType
InstantiatedType.applyCaptureConversion()
. A capture type variable can only occur as a type
argument in an InstantiatedType
constructed by InstantiatedType.applyCaptureConversion()
.isCaptureVariable
in class ReferenceType
public boolean hasCaptureVariable()
Type
ReferenceType
has a capture variable.hasCaptureVariable
in class ParameterType
public boolean isGeneric(boolean ignoreWildcards)
Type
public ReferenceType substitute(Substitution substitution)
ReferenceType
ReferenceType
. If the type is parameterized then replaces
type variables that occur, otherwise returns this type.
This abstract method forces typing of substitutions applied to ReferenceType
objects
without an explicit cast.
substitute
in class TypeVariable
substitution
- the type substitutionpublic TypeVariable createCopyWithBounds(ParameterBound lowerBound, ParameterBound upperBound)
createCopyWithBounds
in class TypeVariable