Interface DeclarationInfo
- All Superinterfaces:
AnnotationTarget
- All Known Subinterfaces:
ClassInfo,FieldInfo,MethodInfo,PackageInfo,ParameterInfo,RecordComponentInfo
A declaration is an element of a program source code.
Declarations are:
- packages
- classes, including interfaces, enums, annotations, and records
- fields
- methods, including constructors
- method parameters, including constructor parameters
- record components
- Since:
- 4.0
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumThe declaration kind: package, class, method, parameter, field, record component. -
Method Summary
Modifier and TypeMethodDescriptiondefault ClassInfoasClass()Returns this declaration as a class.default DeclarationInfoReturns this annotation target as a declaration.default FieldInfoasField()Returns this declaration as a field.default MethodInfoasMethod()Returns this declaration as a method.default PackageInfoReturns this declaration as a package.default ParameterInfoReturns this declaration as a method parameter.default RecordComponentInfoReturns this declaration as a record component.default TypeasType()Returns this annotation target as a type.default booleanisClass()Returns whether this declaration is a class.default booleanReturns whether this annotation target is a declaration.default booleanisField()Returns whether this declaration is a field.default booleanisMethod()Returns whether this declaration is a method.default booleanReturns whether this declaration is a package.default booleanReturns whether this declaration is a method parameter.default booleanReturns whether this declaration is a record component.default booleanisType()Returns whether this annotation target is a type.kind()Returns the kind of this declaration.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
DeclarationInfo.Kind kind()Returns the kind of this declaration.- Returns:
- the kind of this declaration
-
isPackage
default boolean isPackage()Returns whether this declaration is a package.- Returns:
trueif this is a package,falseotherwise
-
isClass
default boolean isClass()Returns whether this declaration is a class.- Returns:
trueif this is a class,falseotherwise
-
isMethod
default boolean isMethod()Returns whether this declaration is a method.- Returns:
trueif this is a method,falseotherwise
-
isParameter
default boolean isParameter()Returns whether this declaration is a method parameter.- Returns:
trueif this is a parameter,falseotherwise
-
isField
default boolean isField()Returns whether this declaration is a field.- Returns:
trueif this is a field,falseotherwise
-
isRecordComponent
default boolean isRecordComponent()Returns whether this declaration is a record component.- Returns:
trueif this is a record component,falseotherwise
-
asPackage
Returns this declaration as a package.- Returns:
- this package, never
null - Throws:
IllegalStateException- ifisPackage()returnsfalse
-
asClass
Returns this declaration as a class.- Returns:
- this class, never
null - Throws:
IllegalStateException- ifisClass()returnsfalse
-
asMethod
Returns this declaration as a method.- Returns:
- this method, never
null - Throws:
IllegalStateException- ifisMethod()returnsfalse
-
asParameter
Returns this declaration as a method parameter.- Returns:
- this parameter, never
null - Throws:
IllegalStateException- ifisParameter()returnsfalse
-
asField
Returns this declaration as a field.- Returns:
- this field, never
null - Throws:
IllegalStateException- ifisField()returnsfalse
-
asRecordComponent
Returns this declaration as a record component.- Returns:
- this record component, never
null - Throws:
IllegalStateException- ifisRecordComponent()returnsfalse
-