Package com.tngtech.archunit.core.domain
Interface JavaType
- All Superinterfaces:
HasName
- All Known Subinterfaces:
JavaParameterizedType
- All Known Implementing Classes:
JavaClass,JavaGenericArrayType,JavaTypeVariable,JavaWildcardType
Represents a general Java type. This can e.g. be a class like
Besides having a
java.lang.String, a parameterized type
like List<String> or a type variable like T.Besides having a
name and offering the possibility to being converted to an
erasure (which is then always a raw class object) JavaType doesn't offer
an extensive API. Instead, users can check a JavaType for being an instance of a concrete subtype
(like JavaTypeVariable) and then cast it to the respective subclass
(same as with Type of the Java Reflection API).-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final classNested classes/interfaces inherited from interface com.tngtech.archunit.core.domain.properties.HasName
HasName.AndFullName, HasName.Predicates, HasName.Utils -
Method Summary
Modifier and TypeMethodDescriptionReturns the set of all raw types that are involved in this type.Converts thisJavaTypeinto the erased type (compare the Java Language Specification).
-
Method Details
-
toErasure
Converts thisJavaTypeinto the erased type (compare the Java Language Specification). In particular this will result in- the class itself, if this type is a
JavaClass - the
JavaClassequivalent toObject, if this type is an unboundJavaTypeVariable - the
JavaClassequivalent to the erasure of the left most bound, if this type is a boundJavaTypeVariable - if this type is a
JavaGenericArrayType, the erasure will be theJavaClassequivalent 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[][]whereTis unbound, then the erasure will be the array typeObject[][]
- the class itself, if this type is a
-
getAllInvolvedRawTypes
Returns the set of all raw types that are involved in this type. If this type is aJavaClass, then this method trivially returns only the class itself. If this type is aJavaParameterizedType,JavaTypeVariable,JavaWildcardType, etc., then this method returns all raw types involved in type arguments and upper and lower bounds recursively. If this type is an array type, then this method returns all raw types involved in the component type of the array type.
Examples:
For the parameterized type
the result would be theList<String>classes[List, String].
For the parameterized type
the result would beMap<? extends Serializable, List<? super Integer[]>>[Map, Serializable, List, Integer].
And for the type variable
the result would beT extends List<? super Integer>[List, Integer].
Thus, this method offers a quick way to determine all types a (possibly complex) type depends on.- Returns:
- All raw types involved in this
JavaType
-