Package com.tngtech.archunit.core.domain
Class JavaWildcardType
- java.lang.Object
-
- com.tngtech.archunit.core.domain.JavaWildcardType
-
- All Implemented Interfaces:
JavaType
,HasName
,HasUpperBounds
public class JavaWildcardType extends java.lang.Object implements JavaType, HasUpperBounds
Represents a wildcard type in a type signature (compare the JLS). Consider the generic typeList<T>
, then the parameterized typeList<?>
would have the wildcard?
as its type argument (also seeJavaParameterizedType
).
According to the JLS a wildcard may have upper and lower bounds.
An upper bound denotes a common supertype any substitution of this wildcard must be assignable to. It is denoted by? extends SomeType
.
A lower bound denotes a common subtype that must be assignable to all substitutions of this wildcard type. It is denoted by? super SomeType
.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.tngtech.archunit.core.domain.properties.HasName
HasName.AndFullName, HasName.Functions, HasName.Predicates
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<JavaType>
getLowerBounds()
java.lang.String
getName()
java.util.List<JavaType>
getUpperBounds()
JavaClass
toErasure()
Converts thisJavaType
into the erased type (compare the Java Language Specification).java.lang.String
toString()
-
-
-
Method Detail
-
getName
@PublicAPI(usage=ACCESS) public java.lang.String getName()
- Specified by:
getName
in interfaceHasName
- Returns:
- The name of this
JavaWildcardType
, which is always "?"
-
getUpperBounds
@PublicAPI(usage=ACCESS) public java.util.List<JavaType> getUpperBounds()
- Specified by:
getUpperBounds
in interfaceHasUpperBounds
- Returns:
- All upper bounds of this
JavaWildcardType
, i.e. supertypes any substitution of this variable must extend. E.g. forList<? extends SomeClass>
the upper bounds would be[SomeClass]
Note that the JLS currently only allows a single upper bound for a wildcard type, but we follow the Reflection API here and support a collection (compareWildcardType.getUpperBounds()
).
-
getLowerBounds
@PublicAPI(usage=ACCESS) public java.util.List<JavaType> getLowerBounds()
- Returns:
- All lower bounds of this
JavaWildcardType
, i.e. any substitution for thisJavaWildcardType
must be a supertype of all lower bounds. E.g. forHandler<? super SomeClass>>
the lower bounds would be[SomeClass]
.
Note that the JLS currently only allows a single lower bound for a wildcard type, but we follow the Reflection API here and support a collection (compareWildcardType.getLowerBounds()
).
-
toErasure
@PublicAPI(usage=ACCESS) public JavaClass toErasure()
Description copied from interface:JavaType
Converts thisJavaType
into the erased type (compare the Java Language Specification). In particular this will result in- the class itself, if this type is a
JavaClass
- the
JavaClass
equivalent toObject
, if this type is an unboundJavaTypeVariable
- the
JavaClass
equivalent to the erasure of the left most bound, if this type is a boundJavaTypeVariable
- if this type is a
JavaGenericArrayType
, the erasure will be theJavaClass
equivalent to the array type that has the erasure of the generic component type of this type as its component type; e.g. take the generic array typeT[][]
whereT
is unbound, then the erasure will be the array typeObject[][]
- the class itself, if this type is a
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-