Record Class SerialDescriptor

java.lang.Object
java.lang.Record
dev.gmitch215.bytebox.io.SerialDescriptor
Record Components:
className - the binary name, with dots and a $ before a nested class's name
serialVersionUID - the declared value, or the one computed from the class's shape
flags - the descriptor flags: 0x02 for serializable, plus 0x10 for an enum
fields - the fields this level declares, primitives first and then references, each group in alphabetical order, which is the order the format fixes

public record SerialDescriptor(String className, long serialVersionUID, byte flags, List<SerialField> fields) extends Record
One class's entry in a stream's class descriptor chain.

A stream describes the whole hierarchy, not just the class being written, because a reader has to know which fields belong to which level. SerialCodec.descriptors() carries the chain.

Since:
1.0.0
  • Field Details

    • SERIALIZABLE

      public static final byte SERIALIZABLE
      A class that takes part in serialization.
      See Also:
    • ENUM

      public static final byte ENUM
      An enum class, whose constants are written by name.
      See Also:
    • JAVA_LANG_ENUM

      public static final SerialDescriptor JAVA_LANG_ENUM
      The descriptor every enum's chain ends with.

      Written by generated code, so it is here rather than kept private: a wrong copy of it would produce a stream a JVM misreads, and SerialConformanceTest checks this one.

  • Constructor Details

    • SerialDescriptor

      public SerialDescriptor(String className, long serialVersionUID, byte flags, List<SerialField> fields)
      Creates an instance of a SerialDescriptor record class.
      Parameters:
      className - the value for the className record component
      serialVersionUID - the value for the serialVersionUID record component
      flags - the value for the flags record component
      fields - the value for the fields record component
  • Method Details

    • 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 '=='.
      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
    • serialVersionUID

      public long serialVersionUID()
      Returns the value of the serialVersionUID record component.
      Returns:
      the value of the serialVersionUID record component
    • flags

      public byte flags()
      Returns the value of the flags record component.
      Returns:
      the value of the flags record component
    • fields

      public List<SerialField> fields()
      Returns the value of the fields record component.
      Returns:
      the value of the fields record component