Annotation Interface Scan
Tells the serialization framework how instances of the class annotated with ConfigurationSerializable
should be serialized and deserialized.
Scan.Type.FIELDS
will generate the serialize and deserialize methods based on the fields present in the class.
The code generation framework uses an empty blacklist. All instance fields are considered by default.
With Scan.ExcludeProperty
this behaviour can be adjusted. Simple annotate a field using this annotation,
and then that field won't be serialized.
Additionally Scan.IncludeProperty
can be used to adjust the name of the yaml property in the serialized form.
If the class does not have a zero-argument constructor, but DeserializationMethod.DESERIALIZE
or DeserializationMethod.VALUE_OF
is used,
then the framework will try to generate a zero-argument constructor in the absence of one, which may lead to unexpected results!
Scan.Type.GETTER_SETTER_METHODS
will generate the serialize and deserialize methods based on the methods present in the class.
The code generation framework uses and empty whitelist. None of the methods are considered by default.
With Scan.IncludeProperty
a pair of methods can be whitelisted. Both the getter method and the setter methods must be annotated!
The annotation also allow you to specify the name of the yaml property that will be used.
The 'adapt' field of the annotation lets the framework guess the name of the property based on java and scala method naming conventions.
Set 'adapt' to false if you want the yaml property to exactly match the name of the method.
If the class does not have a zero-argument constructor, but DeserializationMethod.DESERIALIZE
or DeserializationMethod.VALUE_OF
is used,
then the framework will try to generate a zero-argument constructor in the absence of one, which may lead to unexpected results!
Scan.Type.CASE_CLASS
will generate the serialize and deserialize methods based on the presence of static apply and unapply methods.
These are generated by default by the scala compiler for all case classes, but you could also implement them in a companion object,
or just using static methods in Java (note that you will still need to return a boolean or scala.Option from the unapply method).
Scan.Type.SINGLETON_OBJECT
will cause the serialization framework to always serialize using an empty map, and always use the single instance for deserialization.
This scan type only works for classes defined as an object in Scala.
Scan.Type.RECORD
will cause the serialization framework to serialize and deserialize all record components.
Records were introduced in Java 14 as a preview feature and stabilized in Java 16, so Scala hasn't taken advantage of them yet.
Scan.Type.ENUM
will generate the serialize and deserialize methods to use a Map with only one entry
of which the value will be the name of the enum, as returned by Enum.name()
.
This scan type will only work on Java enums, and also Scala 3 enums that extend java.lang.Enum,
but until then if you want to use this from Scala 2 you must implement the name(): String in your SerializableClass
and valueOf(String): SerializableClass in the companion object.
Scan.Type.AUTO_DETECT
will cause the framework to detect automatically which of the other scan types should be used based on the features of the class.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic @interface
Fields annotated with this annotation will not be considered when generating the serialization and deserialization methods.static @interface
Fields and methods annotated with this annotation will be considered when generating the serialization and deserialization methods.static enum
-
Optional Element Summary
Optional Elements
-
Element Details
-
value
Scan.Type value- Default:
AUTO_DETECT
-