class WildcardType extends ParameterType
A wildcard may have either an upper or lower bound as defined in JLS Section 4.5.1.
? [ extends ReferenceType ] ? [ super ReferenceType ]
WildcardArgument
Modifier and Type | Field and Description |
---|---|
private boolean |
hasUpperBound |
Modifier | Constructor and Description |
---|---|
private |
WildcardType() |
(package private) |
WildcardType(ParameterBound bound,
boolean hasUpperBound) |
Modifier and Type | Method and Description |
---|---|
WildcardType |
applyCaptureConversion()
Applies a capture conversion to this type.
|
boolean |
contains(WildcardType otherType)
If this type has an upper bound, checks for containment cases:
? extends T contains ? extends S if T.isSubtypeOf(S)
? extends T contains ?
Both of which are technically the same because from a reflection perspective ? is just
? extends Object . |
boolean |
equals(@Nullable java.lang.Object obj) |
static WildcardType |
forType(java.lang.reflect.WildcardType type)
Creates a wildcard type from a given reflection type.
|
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.
|
ParameterBound |
getTypeBound()
Returns the bound of this -- either the upper or lower bound.
|
int |
hashCode() |
(package private) boolean |
hasUpperBound()
Returns true if this wildcard has an upper bound.
|
boolean |
isGeneric(boolean ignoreWildcards)
Indicate whether this type is generic.
|
WildcardType |
substitute(Substitution substitution)
Applies a substitution to a
ReferenceType . |
java.lang.String |
toString() |
getCanonicalName, getLowerTypeBound, getRuntimeClass, getTypeParameters, getUpperTypeBound, hasCaptureVariable, hasGenericBound, hasWildcard, setLowerBound, setUpperBound
forClass, forType, getInstantiatingSubstitution, getInstantiatingSubstitutionforTypeVariable, isAssignableFrom, isCaptureVariable, isInstantiationOf, isReferenceType, isSubtypeOf
compareTo, forFullyQualifiedName, forName, forValue, getRawtype, getTypeforFullyQualifiedName, getUnqualifiedBinaryName, isArray, isAssignableFromTypeOf, isBoxedPrimitive, isClass, isClassOrInterfaceType, isEnum, isGeneric, isInterface, isNonreceiverType, isObject, isParameterized, isPrimitive, isRawtype, isString, isVariable, isVoid, runtimeClassIs
private WildcardType()
WildcardType(ParameterBound bound, boolean hasUpperBound)
public static WildcardType forType(java.lang.reflect.WildcardType type)
type
- the java.lang.reflect.WildcardType
objectWildcardType
with the bounds from the given reflection typepublic 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 ParameterType
public 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 ParameterBound getTypeBound()
public WildcardType 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 ReferenceType
substitution
- the type substitutionpublic WildcardType applyCaptureConversion()
Type
applyCaptureConversion
in class ReferenceType
public boolean contains(WildcardType otherType)
? extends T
contains ? extends S
if T.isSubtypeOf(S)
? extends T
contains ?
?
is just
? extends Object
. Otherwise, checks for the cases
? super T
contains ? super S
if S.isSubtypeOf(T)
? super T
contains ?
? super T
contains ? extends Object
otherType
- the type to check forpublic boolean isGeneric(boolean ignoreWildcards)
Type
boolean hasUpperBound()