public interface ClassInfo extends DeclarationInfo
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.
DeclarationInfo.Kind| Modifier and Type | Method and 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 excluding
java.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 is
final. |
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 excluding
java.lang.Object,
as well as all direct and indirect superinterfaces. |
int |
modifiers()
Returns the modifiers of this class as an
int. |
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 by
Class.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 by
Class.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.
|
asDeclaration, asField, asMethod, asPackage, asParameter, asRecordComponent, asType, isClass, isDeclaration, isField, isMethod, isPackage, isParameter, isRecordComponent, isTypeannotation, annotations, annotations, hasAnnotation, hasAnnotation, repeatableAnnotationjava.lang.String name()
Class.getName().nulljava.lang.String simpleName()
Class.getSimpleName().nullPackageInfo packageInfo()
null if this class is part of an unnamed package.null if this class is in an unnamed packagejava.util.List<TypeVariable> typeParameters()
nullType superClass()
null if this class
does not have a superclass; that is, if this class is java.lang.Object or an interface.null if there's no superclassClassInfo superClassDeclaration()
null if this class
does not have a superclass; that is, if this class is java.lang.Object or an interface.null if there's no superclassjava.util.List<Type> superInterfaces()
nulljava.util.List<ClassInfo> superInterfacesDeclarations()
nullboolean isPlainClass()
boolean isInterface()
false.boolean isEnum()
boolean isAnnotation()
boolean isRecord()
boolean isAbstract()
A plain class is abstract if declared abstract.
An enum is abstract if it declares abstract methods.
An interface or an annotation is always abstract.
A record is never abstract.
abstractboolean isFinal()
final.finalint modifiers()
int.
Use Modifier to inspect the value.java.util.Collection<MethodInfo> constructors()
If this class is an interface or an annotation, returns an empty collection.
nulljava.util.Collection<MethodInfo> methods()
java.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.
nulljava.util.Collection<FieldInfo> fields()
java.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 fields
Iteration order of the resulting collection is not defined and does not have to correspond to the inheritance hierarchy of this class.
nulljava.util.Collection<RecordComponentInfo> recordComponents()
nuldefault DeclarationInfo.Kind kind()
DeclarationInfokind in interface DeclarationInfodefault ClassInfo asClass()
DeclarationInfoasClass in interface DeclarationInfonull