Interface ClassInfo
-
- All Superinterfaces:
AnnotationTarget
,DeclarationInfo
public interface ClassInfo extends DeclarationInfo
A class. Five kinds of classes are distinguished:- 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
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default ClassInfo
asClass()
Returns this declaration as a class.java.util.Collection<MethodInfo>
constructors()
Returns a collection of constructors declared or implicitly declared in this class.java.util.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.boolean
isAbstract()
Returns whether this class is abstract.boolean
isAnnotation()
Returns whether this class is an annotation.boolean
isEnum()
Returns whether this class is an enum.boolean
isFinal()
Returns whether this class isfinal
.boolean
isInterface()
Returns whether this class is an interface.boolean
isPlainClass()
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.java.util.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.int
modifiers()
Returns the modifiers of this class as anint
.java.lang.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()
.PackageInfo
packageInfo()
Returns the package this class is part of.java.util.Collection<RecordComponentInfo>
recordComponents()
Returns a collection of record components declared in this class.java.lang.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()
.Type
superClass()
Returns the type of this class's superclass.ClassInfo
superClassDeclaration()
Returns the declaration of this class's superclass.java.util.List<Type>
superInterfaces()
Returns a list of types of this class's direct superinterfaces.java.util.List<ClassInfo>
superInterfacesDeclarations()
Returns a list of declarations of this class's direct superinterfaces.java.util.List<TypeVariable>
typeParameters()
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 Detail
-
name
java.lang.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
java.lang.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
java.util.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
Type superClass()
Returns the type of this class's superclass. Returnsnull
if this class does not have a superclass; that is, if this class isjava.lang.Object
or an interface.- Returns:
- the type of this class's superclass, or
null
if there's no superclass
-
superClassDeclaration
ClassInfo superClassDeclaration()
Returns the declaration of this class's superclass. Returnsnull
if this class does not have a superclass; that is, if this class isjava.lang.Object
or an interface.- Returns:
- the declaration of this class's superclass, or
null
if there's no superclass
-
superInterfaces
java.util.List<Type> superInterfaces()
Returns a list of types of this class's direct superinterfaces. Returns an empty list if this class has no direct superinterface.- Returns:
- immutable list of types of this class's direct superinterfaces, never
null
-
superInterfacesDeclarations
java.util.List<ClassInfo> superInterfacesDeclarations()
Returns a list of declarations of this class's direct superinterfaces. Returns an empty list if this class has no direct superinterface.- Returns:
- immutable list of declarations of this class's direct superinterfaces, never
null
-
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
java.util.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
java.util.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 is an interface, only superinterfaces are considered. Methods implicitly declared 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
java.util.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 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
java.util.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
default DeclarationInfo.Kind kind()
Description copied from interface:DeclarationInfo
Returns the kind of this declaration.- Specified by:
kind
in interfaceDeclarationInfo
- Returns:
- the kind of this declaration
-
asClass
default ClassInfo asClass()
Description copied from interface:DeclarationInfo
Returns this declaration as a class.- Specified by:
asClass
in interfaceDeclarationInfo
- Returns:
- this class, never
null
-
-