An example implementation of Enumeration.
Each Enumeration is implemented as a series of case objects extending a base abstract class, that itself extends Enumeration.
Each Enumeration is implemented as a series of case objects extending a base abstract class,
that itself extends Enumeration. Each case object must override stringVal
, and the stringVal
for each
should be unique across all cases of a given Enumeration; no two objects should have the same stringVal
value,
regardless of uppercase/lowercase.
A simple example runner, demonstrating how to serialize and deserialize objects with Enumerations.
A simple example runner, demonstrating how to serialize and deserialize objects with Enumerations.
The toJson
and fromJson
calls are from implicits in
com.paypal.cascade.json._
.
com.paypal.cascade.json._ }}}
An example implementation of Enumeration.
For a given Enumeration, @JsonSerialize and @JsonDeserialize annotations must be set, and JsonSerializer/JsonDeserializer classes need to be provided for those annotations.
Luckily, most enumeration serializers and deserializers can be copied verbatim from this example, changing type parameters where needed. Delicious boilerplate.