Record Class ClassFileSummary
java.lang.Object
java.lang.Record
net.jrodolfo.java_evolution.java24.class_file.ClassFileSummary
- Record Components:
className- the dotted Java class namemajorVersion- the class-file major versionminorVersion- the class-file minor versionmethodNames- method names declared in the class filefieldNames- field names declared in the class fileaccessFlags- class-level access flags
public record ClassFileSummary(String className, int majorVersion, int minorVersion, List<String> methodNames, List<String> fieldNames, Set<AccessFlag> accessFlags)
extends Record
Summarizes information parsed from a Java
.class file.
The Class-File API exposes class-file structure directly. This record keeps a small learner-friendly subset: class name, class-file version, methods, fields, and access flags.
-
Constructor Summary
ConstructorsConstructorDescriptionClassFileSummary(String className, int majorVersion, int minorVersion, List<String> methodNames, List<String> fieldNames, Set<AccessFlag> accessFlags) Creates an immutable summary. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theaccessFlagsrecord component.Returns the value of theclassNamerecord component.final booleanIndicates whether some other object is "equal to" this one.Returns the value of thefieldNamesrecord component.booleanhasAccessFlag(AccessFlag accessFlag) Checks whether the class has a specific class-level access flag.booleanChecks whether the class file declares a field.final inthashCode()Returns a hash code value for this object.booleanChecks whether the class file declares a method.booleanChecks whether the class file was compiled for Java 24 or newer.intReturns the value of themajorVersionrecord component.Returns the value of themethodNamesrecord component.intReturns the value of theminorVersionrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
ClassFileSummary
-
-
Method Details
-
hasMethod
Checks whether the class file declares a method.- Parameters:
methodName- method name to find- Returns:
truewhen the method exists in the class file
-
hasField
Checks whether the class file declares a field.- Parameters:
fieldName- field name to find- Returns:
truewhen the field exists in the class file
-
isJava24OrNewer
public boolean isJava24OrNewer()Checks whether the class file was compiled for Java 24 or newer.- Returns:
truewhen the class-file major version is at least Java 24
-
hasAccessFlag
Checks whether the class has a specific class-level access flag.- Parameters:
accessFlag- flag to find- Returns:
truewhen the flag is present
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
className
-
majorVersion
public int majorVersion()Returns the value of themajorVersionrecord component.- Returns:
- the value of the
majorVersionrecord component
-
minorVersion
public int minorVersion()Returns the value of theminorVersionrecord component.- Returns:
- the value of the
minorVersionrecord component
-
methodNames
Returns the value of themethodNamesrecord component.- Returns:
- the value of the
methodNamesrecord component
-
fieldNames
Returns the value of thefieldNamesrecord component.- Returns:
- the value of the
fieldNamesrecord component
-
accessFlags
Returns the value of theaccessFlagsrecord component.- Returns:
- the value of the
accessFlagsrecord component
-