Interface Type
- All Superinterfaces:
AnnotationTarget
- All Known Subinterfaces:
ArrayType,ClassType,ParameterizedType,PrimitiveType,TypeVariable,VoidType,WildcardType
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:
- the void pseudo-type
- a primitive type, such as
int - a class type, such as
String - an array type, such as
int[]orString[][] - a parameterized type, such as
List<String> - a type variable, such as
Twhen used in a class that declares a type parameterT - a wildcard type, such as the type argument in
List<? extends Number>
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptiondefault ArrayTypeasArray()Returns this type as an array type.default ClassTypeasClass()Returns this type as a class type.default DeclarationInfoReturns this annotation target as a declaration.default ParameterizedTypeReturns this type as a parameterized type.default PrimitiveTypeReturns this type as a primitive type.default TypeasType()Returns this annotation target as a type.default TypeVariableReturns this type as a type variable.default VoidTypeasVoid()Returns this type as the void pseudo-type.default WildcardTypeReturns this type as a wildcard type.default booleanisArray()Returns whether this type is an array type.default booleanisClass()Returns whether this type is a class type.default booleanReturns whether this annotation target is a declaration.default booleanReturns whether this type is a parameterized type.default booleanReturns whether this type is a primitive type.default booleanisType()Returns whether this annotation target is a type.default booleanReturns whether this type is a type variable.default booleanisVoid()Returns whether this type is the void pseudo-type.default booleanReturns whether this type is a wildcard type.kind()Returns the kind of this type.Methods inherited from interface jakarta.enterprise.lang.model.AnnotationTarget
annotation, annotations, annotations, hasAnnotation, hasAnnotation, repeatableAnnotation
-
Method Details
-
isDeclaration
default boolean isDeclaration()Description copied from interface:AnnotationTargetReturns whether this annotation target is a declaration.- Specified by:
isDeclarationin interfaceAnnotationTarget- Returns:
trueif this is a declaration,falseotherwise
-
isType
default boolean isType()Description copied from interface:AnnotationTargetReturns whether this annotation target is a type.- Specified by:
isTypein interfaceAnnotationTarget- Returns:
trueif this is a type,falseotherwise
-
asDeclaration
Description copied from interface:AnnotationTargetReturns this annotation target as a declaration.- Specified by:
asDeclarationin interfaceAnnotationTarget- Returns:
- this declaration, never
null
-
asType
Description copied from interface:AnnotationTargetReturns this annotation target as a type.- Specified by:
asTypein interfaceAnnotationTarget- Returns:
- this type, never
null
-
kind
Type.Kind kind()Returns the kind of this type.- Returns:
- the kind of this type
-
isVoid
default boolean isVoid()Returns whether this type is the void pseudo-type.- Returns:
trueif this is void,falseotherwise
-
isPrimitive
default boolean isPrimitive()Returns whether this type is a primitive type.- Returns:
trueif this is a primitive type,falseotherwise
-
isClass
default boolean isClass()Returns whether this type is a class type.- Returns:
trueif this is a class type,falseotherwise
-
isArray
default boolean isArray()Returns whether this type is an array type.- Returns:
trueif this is an array type,falseotherwise
-
isParameterizedType
default boolean isParameterizedType()Returns whether this type is a parameterized type.- Returns:
trueif this is a parameterized type,falseotherwise
-
isTypeVariable
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.- Returns:
trueif this is a primitive type,falseotherwise
-
isWildcardType
default boolean isWildcardType()Returns whether this type is a wildcard type.- Returns:
trueif this is a wildcard type,falseotherwise
-
asVoid
Returns this type as the void pseudo-type.- Returns:
- this void type, never
null - Throws:
IllegalStateException- ifisVoid()returnsfalse
-
asPrimitive
Returns this type as a primitive type.- Returns:
- this primitive type, never
null - Throws:
IllegalStateException- ifisPrimitive()returnsfalse
-
asClass
Returns this type as a class type.- Returns:
- this class type, never
null - Throws:
IllegalStateException- ifisClass()returnsfalse
-
asArray
Returns this type as an array type.- Returns:
- this array type, never
null - Throws:
IllegalStateException- ifisArray()returnsfalse
-
asParameterizedType
Returns this type as a parameterized type.- Returns:
- this parameterized type, never
null - Throws:
IllegalStateException- ifisParameterizedType()returnsfalse
-
asTypeVariable
Returns this type as a type variable. Type variables are also used to represent type parameters in declarations of parameterized types.- Returns:
- this type variable, never
null - Throws:
IllegalStateException- ifisTypeVariable()returnsfalse
-
asWildcardType
Returns this type as a wildcard type.- Returns:
- this wildcard type, never
null - Throws:
IllegalStateException- ifisWildcardType()returnsfalse
-