{8.1.0-new} Auto-detected POJO swaps
Various methods can be defined on a class directly to affect how it gets serialized.
This can often be simpler than using
Objects serialized as
Note that these methods cover conversion from several built-in Java types, meaning the parsers can automatically construct these objects from strings:
If you want to force a bean-like class to be serialized as a string, you can use the
{@link oaj.annotation.BeanIgnore @BeanIgnore} annotation on the class to force it to be
serialized to a string using the
Serializing to other intermediate objects can be accomplished by defining a swap method directly on the class:
Serializing to and from Maps can be accomplished by defining any of the following methods:
The
The following example shows how an HTML5 form template object can be created that gets serialized as a populated HTML5 {@link oaj.dto.html5.Form} bean.
Swapped objects can be converted back into their original form by the parsers by specifying one of the following methods:
The following shows how our form template class can be modified to allow the parsers to reconstruct our original object: