In the Java language, array types have a component type and an element type. An element type
is never an array type; it is the ultimate type obtained after all array dimensions are removed.
For example, an element type of String[][] is String. A component type is
the element type in case of one-dimensional arrays, and the same array type with one dimension
less in case of multidimensional arrays. For example, the component type of String[][]
is String[], whose component type is String. The number of dimensions can only
be found by obtaining the component type repeatedly, until the element type is reached.
On the other hand, the Jandex representation is compressed. It consists of a constituent type
and a number of dimensions. In case the array type does not contain type annotations,
the constituent type is the element type. For example, the array type String[][] has
2 dimensions and a constituent type of String. However, to faithfully represent type
annotations, array types may be nested; that is, the constituent type may be another array type.
For example, the array type of String[] @Ann [] has 1 dimension and a constituent type
of String @Ann []. In turn, this array type has 1 dimension and a constituent type
of String.
The constituent() and dimensions() methods provide access to the Jandex
native representation. The elementType() and componentType() methods,
as well as deepDimensions(), provide access to the Java language representation.
The component() method is present for backwards compatibility and should not be used.
It is equivalent to the constituent() method.
| Modifier and Type | Class and Description |
|---|---|
| public static class | ArrayType.Builder
Convenient builder for |
| Modifier and Type | Field and Description |
|---|---|
| private final Type | |
| private final int | |
| private int |
| Access | Constructor and Description |
|---|---|
| pack-priv | |
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| private void | |
| public ArrayType | asArrayType()
Overrides org. org. and returns it if the kind is
Kind#ARRAY.
|
| public static ArrayType. | |
| public Type | |
| public Type | |
| public Type | |
| pack-priv Type | |
| pack-priv Type | |
| public static ArrayType | |
| public int | Returns: the "deep" number of dimensions of this array typeThe total number of dimensions this array type has, when traversed deep to the element type. |
| public int | Returns: the number of dimensions of this array typeThe number of dimensions this array type has. |
| public Type | |
| public boolean | equals(Object
the type to compare to o)Overrides org. Type with another type.
|
| public int | |
| pack-priv boolean | |
| pack-priv int | |
| public Type. | |
| public DotName | name()
Overrides org. DotName,
using the Class#getName() format.
|
| pack-priv String |
| constituent | back to summary |
|---|---|
| private final Type constituent | |
| dimensions | back to summary |
|---|---|
| private final int dimensions | |
| hash | back to summary |
|---|---|
| private int hash | |
| ArrayType | back to summary |
|---|---|
| pack-priv ArrayType(Type constituent, int dimensions) | |
| ArrayType | back to summary |
|---|---|
| pack-priv ArrayType(Type constituent, int dimensions, AnnotationInstance[] annotations) | |
| appendArraySyntax | back to summary |
|---|---|
| private void appendArraySyntax(StringBuilder builder) | |
| appendRootComponent | back to summary |
|---|---|
| private void appendRootComponent(StringBuilder builder, boolean simple) | |
| asArrayType | back to summary |
|---|---|
| public ArrayType asArrayType() Overrides org. Doc from org. Casts this type to an | |
| builder | back to summary |
|---|---|
| public static ArrayType. Create a builder of an array type.
| |
| component | back to summary |
|---|---|
| public Type component()
Deprecated use Equivalent to
This method provides access to the Jandex compressed representation of array types.
It is likely you want to use
| |
| componentType | back to summary |
|---|---|
| public Type componentType() Returns the component type of the array. For example,
| |
| constituent | back to summary |
|---|---|
| public Type constituent() Returns the constituent type of the array. Note that it may be another array type in case
type annotations are present on the array components. For example,
This method provides access to the Jandex compressed representation of array types.
It is likely you want to use
| |
| copyType | back to summary |
|---|---|
| pack-priv Type copyType(AnnotationInstance[] newAnnotations) Implements abstract org.
| |
| copyType | back to summary |
|---|---|
| pack-priv Type copyType(Type component, int dimensions) | |
| create | back to summary |
|---|---|
| public static ArrayType create(Type constituent, int dimensions) Create a new array type instance with the specified number of dimensions and the specified constituent type.
| |
| deepDimensions | back to summary |
|---|---|
| public int deepDimensions() The total number of dimensions this array type has, when traversed deep to the element type.
For example, both
This method is different to
| |
| dimensions | back to summary |
|---|---|
| public int dimensions() The number of dimensions this array type has. Note that the constituent type may be an array
type, so the number of dimensions does not necessarily correspond to the number of times
an array dimension would have to be removed from this array type to reach its element type.
For example, this method would return 2 for an array type of
This method is different to
This method provides access to the Jandex compressed representation of array types.
It is likely you want to use
| |
| elementType | back to summary |
|---|---|
| public Type elementType() Returns the element type of the array. For example, both
This method never returns an
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object o) Overrides org. Doc from org. Compares this | |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides org. Doc from org. Computes a hash code representing this type.
| |
| internEquals | back to summary |
|---|---|
| pack-priv boolean internEquals(Object o) Overrides org.
| |
| internHashCode | back to summary |
|---|---|
| pack-priv int internHashCode() Overrides org.
| |
| kind | back to summary |
|---|---|
| public Type. Implements abstract org. Doc from org. Returns the kind of Type this is. | |
| name | back to summary |
|---|---|
| public DotName name() Overrides org. Doc from org. Returns the name of this type (or its erasure in case of generic types) as a
| |
| toString | back to summary |
|---|---|
| pack-priv String toString(boolean simple) Overrides org.
| |
ArrayType.
| Modifier and Type | Field and Description |
|---|---|
| private final Type | |
| private final int |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public ArrayType |
| constituent | back to summary |
|---|---|
| private final Type constituent | |
| dimensions | back to summary |
|---|---|
| private final int dimensions | |
| Builder | back to summary |
|---|---|
| pack-priv Builder(Type constituent, int dimensions) | |
| build | back to summary |
|---|---|
| public ArrayType build() Returns the built array type.
| |