Interface ClassInfo
- All Superinterfaces:
AnnotationTarget
,DeclarationInfo
- plain classes
- interfaces
- enums (restricted kind of classes)
- annotations (specialized kind of interfaces)
- records (restricted kind of classes)
At the same time, it is possible to obtain the set of constructors, methods and fields declared in this class, as well as the set of record components if this class is a record. It is also possible to obtain the package this class is declared in.
- Since:
- 4.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface jakarta.enterprise.lang.model.declarations.DeclarationInfo
DeclarationInfo.Kind
-
Method Summary
Modifier and TypeMethodDescriptiondefault ClassInfo
asClass()
Returns this declaration as a class.Returns a collection of constructors declared or implicitly declared in this class.fields()
Returns a collection of fields declared or implicitly declared in this class and all its superclasses up to and excludingjava.lang.Object
, as well as all direct and indirect superinterfaces.boolean
Returns whether this class is abstract.boolean
Returns whether this class is an annotation.boolean
isEnum()
Returns whether this class is an enum.boolean
isFinal()
Returns whether this class isfinal
.boolean
Returns whether this class is an interface.boolean
Returns whether this class is a plain class.boolean
isRecord()
Returns whether this class is a record.default DeclarationInfo.Kind
kind()
Returns the kind of this declaration.methods()
Returns a collection of methods declared or implicitly declared in this class and all its superclasses up to and excludingjava.lang.Object
, as well as all direct and indirect superinterfaces.int
Returns the modifiers of this class as anint
.name()
Returns the binary name of this class, as defined by The Java™ Language Specification; in other words, the class name as returned byClass.getName()
.Returns the package this class is part of.Returns a collection of record components declared in this class.Returns the simple name of this class, as defined by The Java™ Language Specification; in other words, the class name as returned byClass.getSimpleName()
.Returns the direct superclass type of this class.Returns the direct superclass of this class.Returns a list of direct superinterface types of this class.Returns a list of direct superinterfaces of this class.Returns a list of type parameters declared on this class.Methods inherited from interface jakarta.enterprise.lang.model.AnnotationTarget
annotation, annotations, annotations, hasAnnotation, hasAnnotation, repeatableAnnotation
Methods inherited from interface jakarta.enterprise.lang.model.declarations.DeclarationInfo
asDeclaration, asField, asMethod, asPackage, asParameter, asRecordComponent, asType, isClass, isDeclaration, isField, isMethod, isPackage, isParameter, isRecordComponent, isType
-
Method Details
-
name
String name()Returns the binary name of this class, as defined by The Java™ Language Specification; in other words, the class name as returned byClass.getName()
.- Returns:
- binary name of this class, never
null
-
simpleName
String simpleName()Returns the simple name of this class, as defined by The Java™ Language Specification; in other words, the class name as returned byClass.getSimpleName()
.- Returns:
- simple name of this class, never
null
-
packageInfo
PackageInfo packageInfo()Returns the package this class is part of. Returnsnull
if this class is part of an unnamed package.- Returns:
- this class's package, or
null
if this class is in an unnamed package
-
typeParameters
List<TypeVariable> typeParameters()Returns a list of type parameters declared on this class. Returns an empty list if this class is not generic and so does not declare type parameters.- Returns:
- immutable list of this class's type parameters, never
null
-
superClass
-
superClassDeclaration
ClassInfo superClassDeclaration()Returns the direct superclass of this class. Returnsnull
if this class does not have a superclass; that is, if this class isjava.lang.Object
or an interface.- Returns:
- the direct superclass of this class, or
null
if there's no superclass
-
superInterfaces
-
superInterfacesDeclarations
-
isPlainClass
boolean isPlainClass()Returns whether this class is a plain class. That is, not an interface, not an enum, not an annotation, and not a record.- Returns:
- whether this class is a plain class
-
isInterface
boolean isInterface()Returns whether this class is an interface. If this class is an annotation, returnsfalse
.- Returns:
- whether this class is an interface
-
isEnum
boolean isEnum()Returns whether this class is an enum.- Returns:
- whether this class is an enum
-
isAnnotation
boolean isAnnotation()Returns whether this class is an annotation.- Returns:
- whether this class is an annotation
-
isRecord
boolean isRecord()Returns whether this class is a record.- Returns:
- whether this class is a record
-
isAbstract
boolean isAbstract()Returns whether this class is abstract.A plain class is abstract if declared
abstract
. An enum is abstract if it declaresabstract
methods. An interface or an annotation is always abstract. A record is never abstract.- Returns:
- whether this class is
abstract
-
isFinal
boolean isFinal()Returns whether this class isfinal
.- Returns:
- whether this class is
final
-
modifiers
int modifiers()Returns the modifiers of this class as anint
. UseModifier
to inspect the value.- Returns:
- the modifiers of this class
-
constructors
Collection<MethodInfo> constructors()Returns a collection of constructors declared or implicitly declared in this class. Constructors declared in direct or indirect superclasses are not included.If this class is an interface or an annotation, returns an empty collection.
- Returns:
- immutable collection of constructors, never
null
-
methods
Collection<MethodInfo> methods()Returns a collection of methods declared or implicitly declared in this class and all its superclasses up to and excludingjava.lang.Object
, as well as all direct and indirect superinterfaces. If this class isjava.lang.Object
, its methods are not excluded. If this class is an interface, only superinterfaces are considered. Implicitly declared methods corresponding tojava.lang.Object
methods in interfaces are omitted.If the collection of methods described above contains multiple methods with the same signature, all such methods are returned.
MethodInfo.declaringClass
should be used to distinguish such methods.Iteration order of the resulting collection is not defined and does not have to correspond to the inheritance hierarchy of this class.
- Returns:
- immutable collection of methods, never
null
-
fields
Collection<FieldInfo> fields()Returns a collection of fields declared or implicitly declared in this class and all its superclasses up to and excludingjava.lang.Object
, as well as all direct and indirect superinterfaces. If this class isjava.lang.Object
, its fields are not excluded. If this class is an interface, only superinterfaces are considered.If the collection of fields described above contains multiple fields with the same name, all such fields are returned.
FieldInfo.declaringClass
should be used to distinguish such fieldsIteration order of the resulting collection is not defined and does not have to correspond to the inheritance hierarchy of this class.
- Returns:
- immutable collection of fields, never
null
-
recordComponents
Collection<RecordComponentInfo> recordComponents()Returns a collection of record components declared in this class. If this class is not a record, returns an empty collection.- Returns:
- immutable collection of record components, never
nul
-
kind
Description copied from interface:DeclarationInfo
Returns the kind of this declaration.- Specified by:
kind
in interfaceDeclarationInfo
- Returns:
- the kind of this declaration
-
asClass
Description copied from interface:DeclarationInfo
Returns this declaration as a class.- Specified by:
asClass
in interfaceDeclarationInfo
- Returns:
- this class, never
null
-