For example, the int type exists even if it is not declared in any Java source file, while
the java.lang.String type is declared by the class of the same name. Array types,
such as int[] or String[][], are not declared anywhere either, but their
element types may be. A generic class, such as java.util.List, declares a raw type
of the same name, but it does not declare the parameterized types, such as List<String>.
Parameterized types are created by applying type arguments to generic classes. For example,
the List<String> type is created by applying String to List<T>.
Types occur on many places. A field has a type, a method has a return type, a method parameter
has a type, even the extends clause in a class declaration contains a type.
Occurences of types may be annotated.
Types are:
intStringint[] or String[][]List<String>T when used in a class that declares a type parameter
TList<? extends Number>| Modifier and Type | Class and Description |
|---|---|
| public static enum | Type.
The type kind: void, primitive, class, array, parameterized type, type variable, wildcard type |
| Modifier and Type | Method and Description |
|---|---|
| public default ArrayType | |
| public default ClassType | |
| public default DeclarationInfo | asDeclaration()
Implements jakarta. Returns this annotation target as a declaration. |
| public default ParameterizedType | Returns: this parameterized type, nevernullReturns this type as a parameterized type. |
| public default PrimitiveType | |
| public default Type | asType()
Implements jakarta. Returns this annotation target as a type. |
| public default TypeVariable | |
| public default VoidType | |
| public default WildcardType | |
| public default boolean | |
| public default boolean | |
| public default boolean | isDeclaration()
Implements jakarta. Returns whether this annotation target is a declaration. |
| public default boolean | Returns: true if this is a parameterized type, false otherwiseReturns whether this type is a parameterized type. |
| public default boolean | Returns: true if this is a primitive type, false otherwiseReturns whether this type is a primitive type. |
| public default boolean | isType()
Implements jakarta. Returns whether this annotation target is a type. |
| public default boolean | Returns: true if this is a primitive type, false otherwiseReturns whether this type is a type variable. |
| public default boolean | |
| public default boolean | Returns: true if this is a wildcard type, false otherwiseReturns whether this type is a wildcard type. |
| public Type. |
| asArray | back to summary |
|---|---|
| public default ArrayType asArray() Returns this type as an array type.
| |
| asClass | back to summary |
|---|---|
| public default ClassType asClass() Returns this type as a class type.
| |
| asDeclaration | back to summary |
|---|---|
| public default DeclarationInfo asDeclaration() Implements jakarta. Doc from jakarta. Returns this annotation target as a declaration.
| |
| asParameterizedType | back to summary |
|---|---|
| public default ParameterizedType asParameterizedType() Returns this type as a parameterized type.
| |
| asPrimitive | back to summary |
|---|---|
| public default PrimitiveType asPrimitive() Returns this type as a primitive type.
| |
| asType | back to summary |
|---|---|
| public default Type asType() Implements jakarta. Doc from jakarta. Returns this annotation target as a type. | |
| asTypeVariable | back to summary |
|---|---|
| public default TypeVariable asTypeVariable() Returns this type as a type variable. Type variables are also used to represent type parameters in declarations of parameterized types.
| |
| asVoid | back to summary |
|---|---|
| public default VoidType asVoid() Returns this type as the void pseudo-type.
| |
| asWildcardType | back to summary |
|---|---|
| public default WildcardType asWildcardType() Returns this type as a wildcard type.
| |
| isArray | back to summary |
|---|---|
| public default boolean isArray() Returns whether this type is an array type.
| |
| isClass | back to summary |
|---|---|
| public default boolean isClass() Returns whether this type is a class type.
| |
| isDeclaration | back to summary |
|---|---|
| public default boolean isDeclaration() Implements jakarta. Doc from jakarta. Returns whether this annotation target is a declaration.
| |
| isParameterizedType | back to summary |
|---|---|
| public default boolean isParameterizedType() Returns whether this type is a parameterized type.
| |
| isPrimitive | back to summary |
|---|---|
| public default boolean isPrimitive() Returns whether this type is a primitive type.
| |
| isType | back to summary |
|---|---|
| public default boolean isType() Implements jakarta. Doc from jakarta. Returns whether this annotation target is a type.
| |
| isTypeVariable | back to summary |
|---|---|
| public default boolean isTypeVariable() Returns whether this type is a type variable. Type variables are also used to represent type parameters in declarations of parameterized types.
| |
| isVoid | back to summary |
|---|---|
| public default boolean isVoid() Returns whether this type is the void pseudo-type.
| |
| isWildcardType | back to summary |
|---|---|
| public default boolean isWildcardType() Returns whether this type is a wildcard type.
| |
| kind | back to summary |
|---|---|
| public Type. Returns the kind of this type. | |
| Modifier and Type | Field and Description |
|---|---|
| public static final Type. | ARRAY
An array type, e.g. when method returns |
| public static final Type. | CLASS
A class type, e.g. when method returns |
| public static final Type. | PARAMETERIZED_TYPE
A parameterized type, e.g. when method returns |
| public static final Type. | PRIMITIVE
A primitive type, e.g. when method returns |
| public static final Type. | TYPE_VARIABLE
A type variable, e.g. when method returns |
| public static final Type. | VOID
The void pseudo-type, e.g. when method returns |
| public static final Type. | WILDCARD_TYPE
A wildcard type, e.g. when method returns |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static Type. | |
| public static Type. |
| ARRAY | back to summary |
|---|---|
| public static final Type. An array type, e.g. when method returns | |
| CLASS | back to summary |
|---|---|
| public static final Type. A class type, e.g. when method returns | |
| PARAMETERIZED_TYPE | back to summary |
|---|---|
| public static final Type. A parameterized type, e.g. when method returns | |
| PRIMITIVE | back to summary |
|---|---|
| public static final Type. A primitive type, e.g. when method returns | |
| TYPE_VARIABLE | back to summary |
|---|---|
| public static final Type. A type variable, e.g. when method returns | |
| VOID | back to summary |
|---|---|
| public static final Type. The void pseudo-type, e.g. when method returns | |
| WILDCARD_TYPE | back to summary |
|---|---|
| public static final Type. A wildcard type, e.g. when method returns | |
| Kind | back to summary |
|---|---|
| private Kind() | |
| valueOf | back to summary |
|---|---|
| public static Type. | |
| values | back to summary |
|---|---|
| public static Type. | |