Package randoop.types
Class WildcardType
- java.lang.Object
-
- randoop.types.Type
-
- randoop.types.ReferenceType
-
- randoop.types.ParameterType
-
- randoop.types.WildcardType
-
- All Implemented Interfaces:
Comparable<Type>
class WildcardType extends ParameterType
Represents a wildcard type, which occurs as a type argument to a parameterized type.A wildcard may have either an upper or lower bound as defined in JLS Section 4.5.1.
? [ extends ReferenceType ] ? [ super ReferenceType ]
- See Also:
WildcardArgument
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
hasUpperBound
-
Constructor Summary
Constructors Modifier Constructor Description private
WildcardType()
(package private)
WildcardType(ParameterBound bound, boolean hasUpperBound)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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
ifT.isSubtypeOf(S)
? extends T
contains?
Both of which are technically the same because from a reflection perspective?
is just? extends Object
.boolean
equals(Object obj)
static WildcardType
forType(WildcardType type)
Creates a wildcard type from a given reflection type.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).String
getFqName()
Returns the fully-qualified name of this type, including type arguments if this is a parameterized type.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()
boolean
isGeneric(boolean ignoreWildcards)
Indicate whether this type is generic.WildcardType
substitute(Substitution substitution)
Applies a substitution to aReferenceType
.String
toString()
-
Methods inherited from class randoop.types.ParameterType
getCanonicalName, getLowerTypeBound, getRuntimeClass, getTypeParameters, getUpperTypeBound, hasCaptureVariable, hasGenericBound, hasWildcard, setLowerBound, setUpperBound
-
Methods inherited from class randoop.types.ReferenceType
forClass, forType, getInstantiatingSubstitution, getInstantiatingSubstitutionforTypeVariable, isAssignableFrom, isCaptureVariable, isInstantiationOf, isReferenceType, isSubtypeOf
-
Methods inherited from class randoop.types.Type
compareTo, forFullyQualifiedName, forName, forValue, getRawtype, getTypeforFullyQualifiedName, getUnqualifiedBinaryName, isArray, isAssignableFromTypeOf, isBoxedPrimitive, isClass, isClassOrInterfaceType, isEnum, isGeneric, isInterface, isNonreceiverType, isObject, isParameterized, isPrimitive, isRawtype, isString, isVariable, isVoid, runtimeClassIs
-
-
-
-
Constructor Detail
-
WildcardType
private WildcardType()
-
WildcardType
WildcardType(ParameterBound bound, boolean hasUpperBound)
-
-
Method Detail
-
forType
public static WildcardType forType(WildcardType type)
Creates a wildcard type from a given reflection type. Assumes that the bounds array has a single element as defined in JLS Section 4.5.1.- Parameters:
type
- thejava.lang.reflect.WildcardType
object- Returns:
- a
WildcardType
with the bounds from the given reflection type
-
equals
public boolean equals(Object obj)
- Overrides:
equals
in classParameterType
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classParameterType
-
toString
public String toString()
- Overrides:
toString
in classParameterType
-
getFqName
public String getFqName()
Description copied from class:Type
Returns the fully-qualified name of this type, including type arguments if this is a parameterized type. Forjava.util.List<T>
return"java.util.List<T>"
.
-
getBinaryName
public String getBinaryName()
Description copied from class:Type
Returns the binary name of this type, including type arguments if this is a parameterized type (so, it isn't really a binary name). Forjava.util.List<T>
return"java.util.List<T>"
.- Specified by:
getBinaryName
in classType
- Returns:
- the binary name for this type
-
getSimpleName
public String getSimpleName()
Description copied from class:Type
Returns the name of this type without type arguments or package qualifiers. Forjava.util.List<T>
, returns"List"
.- Specified by:
getSimpleName
in classType
- Returns:
- the name of this type without type arguments
-
getTypeBound
public ParameterBound getTypeBound()
Returns the bound of this -- either the upper or lower bound.- Returns:
- the bound of this -- either the upper or lower bound
-
substitute
public WildcardType substitute(Substitution substitution)
Description copied from class:ReferenceType
Applies a substitution to aReferenceType
. 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.- Specified by:
substitute
in classReferenceType
- Parameters:
substitution
- the type substitution- Returns:
- the type created by applying the substitution to this type
-
applyCaptureConversion
public WildcardType applyCaptureConversion()
Description copied from class:Type
Applies a capture conversion to this type.- Overrides:
applyCaptureConversion
in classReferenceType
- Returns:
- a copy of this type with wildcards replaced by type conversion
-
contains
public boolean contains(WildcardType otherType)
If this type has an upper bound, checks for containment cases:? extends T
contains? extends S
ifT.isSubtypeOf(S)
? extends T
contains?
?
is just? extends Object
. Otherwise, checks for the cases? super T
contains? super S
ifS.isSubtypeOf(T)
? super T
contains?
? super T
contains? extends Object
- Parameters:
otherType
- the type to check for- Returns:
- true if this type contains the other type, false otherwise
-
isGeneric
public boolean isGeneric(boolean ignoreWildcards)
Description copied from class:Type
Indicate whether this type is generic. A type is generic if it has one or more type variables.
-
hasUpperBound
boolean hasUpperBound()
-
-