Enum Class AccessorType

java.lang.Object
java.lang.Enum<AccessorType>
org.gittorr.ccerial.AccessorType
All Implemented Interfaces:
Serializable, Comparable<AccessorType>, Constable

public enum AccessorType extends Enum<AccessorType>
The AccessorType enum defines the methods by which fields of a class annotated with CcSerializable are accessed during serialization and deserialization. This allows fine-grained control over how object data is read and written.

Usage:

  • SETTER: Uses setter methods to assign values during deserialization.
  • FIELD: Directly accesses fields, bypassing getter/setter methods.
  • CONSTRUCTOR: Uses a constructor to set fields during deserialization.

Examples:


 @CcSerializable(accessorType = AccessorType.SETTER)
 public class User {
     private String name;
     private int age;

     public void setName(String name) {
         this.name = name;
     }
     public void setAge(int age) {
         this.age = age;
     }
 }

 @CcSerializable(accessorType = AccessorType.CONSTRUCTOR)
 public record UserRecord(String name, int age) {}
 
  • Enum Constant Details

    • SETTER

      public static final AccessorType SETTER
      Access fields using setter methods. This option requires that setter methods are available for all fields.
    • FIELD

      public static final AccessorType FIELD
      Access fields directly, bypassing getter and setter methods. This may require that fields are accessible (e.g., non-private).
    • CONSTRUCTOR

      public static final AccessorType CONSTRUCTOR
      Use the constructor to set all fields during deserialization. This option requires that a compatible constructor is available.
  • Method Details

    • values

      public static AccessorType[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static AccessorType valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null