Package org.gittorr.ccerial
Enum Class AccessorType
- All Implemented Interfaces:
Serializable,Comparable<AccessorType>,Constable
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) {}
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionUse the constructor to set all fields during deserialization.Access fields directly, bypassing getter and setter methods.Access fields using setter methods. -
Method Summary
Modifier and TypeMethodDescriptionstatic AccessorTypeReturns the enum constant of this class with the specified name.static AccessorType[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
SETTER
Access fields using setter methods. This option requires that setter methods are available for all fields. -
FIELD
Access fields directly, bypassing getter and setter methods. This may require that fields are accessible (e.g., non-private). -
CONSTRUCTOR
Use the constructor to set all fields during deserialization. This option requires that a compatible constructor is available.
-
-
Method Details
-
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
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 nameNullPointerException- if the argument is null
-