Package com.tngtech.archunit.core.domain
Class JavaTypeVariable<OWNER extends HasDescription>
java.lang.Object
com.tngtech.archunit.core.domain.JavaTypeVariable<OWNER>
- All Implemented Interfaces:
JavaType
,HasName
,HasOwner<OWNER>
,HasUpperBounds
@PublicAPI(usage=ACCESS)
public final class JavaTypeVariable<OWNER extends HasDescription>
extends Object
implements JavaType, HasOwner<OWNER>, HasUpperBounds
Represents a type variable used by generic types and members.
E.g.
A type variable can have several bounds, where only one bound may be a class bound while all further bounds must be interfaces (compare the JLS).
Example:
E.g.
class MyClass<T>
would have one JavaTypeVariable
with name "T"
and unbound, i.e. only bound by Object
.A type variable can have several bounds, where only one bound may be a class bound while all further bounds must be interfaces (compare the JLS).
Example:
class MyClass<T extends SomeClass & SomeInterfaceOne & SomeInterfaceTwo>
would declare one JavaTypeVariable
T
which is bound by SomeClass
,
SomeInterfaceOne
and SomeInterfaceTwo
. I.e. any concrete class
substituted for the type variable must extend SomeClass
and implement
SomeInterfaceOne
and SomeInterfaceTwo
.-
Nested Class Summary
Nested classes/interfaces inherited from interface com.tngtech.archunit.core.domain.properties.HasName
HasName.AndFullName, HasName.Predicates, HasName.Utils
Nested classes/interfaces inherited from interface com.tngtech.archunit.core.domain.properties.HasOwner
HasOwner.Functions, HasOwner.Predicates
Nested classes/interfaces inherited from interface com.tngtech.archunit.core.domain.JavaType
JavaType.Functions
-
Method Summary
Modifier and TypeMethodDescriptionThis method is simply an alias forgetUpperBounds()
that is more familiar to users of the Java Reflection API.This method is simply an alias forgetOwner()
that is more familiar to users of the Java Reflection API.getName()
getOwner()
Converts thisJavaType
into the erased type (compare the Java Language Specification).toString()
-
Method Details
-
getName
- Specified by:
getName
in interfaceHasName
- Returns:
- The name of this
JavaTypeVariable
, e.g. forclass MyClass<T>
the name would be "T"
-
getGenericDeclaration
This method is simply an alias forgetOwner()
that is more familiar to users of the Java Reflection API.- See Also:
-
getOwner
- Specified by:
getOwner
in interfaceHasOwner<OWNER extends HasDescription>
- Returns:
- The 'owner' of this type parameter, i.e. the Java object that declared this
TypeVariable
as a type parameter. For type parameterT
ofSomeClass<T>
this would be theJavaClass
representingSomeClass
-
getBounds
This method is simply an alias forgetUpperBounds()
that is more familiar to users of the Java Reflection API.- See Also:
-
getUpperBounds
- Specified by:
getUpperBounds
in interfaceHasUpperBounds
- Returns:
- All upper bounds of this
JavaTypeVariable
, i.e. super types any substitution of this variable must extend. E.g. forclass MyClass<T extends SomeClass & SomeInterface>
the upper bounds would beSomeClass
andSomeInterface
-
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
-