Record Class ClassFileSummary

java.lang.Object
java.lang.Record
net.jrodolfo.java_evolution.java24.class_file.ClassFileSummary
Record Components:
className - the dotted Java class name
majorVersion - the class-file major version
minorVersion - the class-file minor version
methodNames - method names declared in the class file
fieldNames - field names declared in the class file
accessFlags - 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 Details

    • ClassFileSummary

      public ClassFileSummary(String className, int majorVersion, int minorVersion, List<String> methodNames, List<String> fieldNames, Set<AccessFlag> accessFlags)
      Creates an immutable summary.
  • Method Details

    • hasMethod

      public boolean hasMethod(String methodName)
      Checks whether the class file declares a method.
      Parameters:
      methodName - method name to find
      Returns:
      true when the method exists in the class file
    • hasField

      public boolean hasField(String fieldName)
      Checks whether the class file declares a field.
      Parameters:
      fieldName - field name to find
      Returns:
      true when the field exists in the class file
    • isJava24OrNewer

      public boolean isJava24OrNewer()
      Checks whether the class file was compiled for Java 24 or newer.
      Returns:
      true when the class-file major version is at least Java 24
    • hasAccessFlag

      public boolean hasAccessFlag(AccessFlag accessFlag)
      Checks whether the class has a specific class-level access flag.
      Parameters:
      accessFlag - flag to find
      Returns:
      true when the flag is present
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • className

      public String className()
      Returns the value of the className record component.
      Returns:
      the value of the className record component
    • majorVersion

      public int majorVersion()
      Returns the value of the majorVersion record component.
      Returns:
      the value of the majorVersion record component
    • minorVersion

      public int minorVersion()
      Returns the value of the minorVersion record component.
      Returns:
      the value of the minorVersion record component
    • methodNames

      public List<String> methodNames()
      Returns the value of the methodNames record component.
      Returns:
      the value of the methodNames record component
    • fieldNames

      public List<String> fieldNames()
      Returns the value of the fieldNames record component.
      Returns:
      the value of the fieldNames record component
    • accessFlags

      public Set<AccessFlag> accessFlags()
      Returns the value of the accessFlags record component.
      Returns:
      the value of the accessFlags record component