Class JavaGenericArrayType

java.lang.Object
com.tngtech.archunit.core.domain.JavaGenericArrayType
All Implemented Interfaces:
JavaType, HasName

@PublicAPI(usage=ACCESS)
public final class JavaGenericArrayType
extends java.lang.Object
implements JavaType
Represents a generic array type used in signatures of parameterized types.
E.g. for MyClass<A, T extends List<A[]>> the upper bound List<A[]> would have one JavaGenericArrayType A[] as its type parameter.
Like its concrete counterpart a JavaGenericArrayType can be queried for its component type, which can be a JavaParameterizedType, a JavaTypeVariable or a JavaGenericArrayType corresponding to a lower dimensional array.
  • Method Details

    • getName

      @PublicAPI(usage=ACCESS) public java.lang.String getName()
      Specified by:
      getName in interface HasName
      Returns:
      The name of this JavaGenericArrayType, e.g. for A[] within signature MyClass<A, T extends List<A[]>> the name would be "A[]"
    • getComponentType

      @PublicAPI(usage=ACCESS) public JavaType getComponentType()
      Returns:
      The component type of this JavaGenericArrayType, e.g. for A[] within signature MyClass<A, T extends List<A[]>> the component type would be A, while for A[][] within MyClass<A, T extends List<A[][]>> the component type would be A[].
    • toErasure

      @PublicAPI(usage=ACCESS) public JavaClass toErasure()
      Description copied from interface: JavaType
      Converts this JavaType 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 to Object, if this type is an unbound JavaTypeVariable
      • the JavaClass equivalent to the erasure of the left most bound, if this type is a bound JavaTypeVariable
      • if this type is a JavaGenericArrayType, the erasure will be the JavaClass 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 type T[][] where T is unbound, then the erasure will be the array type Object[][]
      Specified by:
      toErasure in interface JavaType
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object