Class JacksonMigration
java.lang.Object
org.apache.pekko.serialization.jackson.JacksonMigration
Data migration of old formats to current format can
be implemented in a concrete subclass and configured to
be used by the
JacksonSerializer for a changed class.
It is used when deserializing data of older version than the
currentVersion(). You implement the transformation of the
JSON structure in the transform(int, com.fasterxml.jackson.databind.JsonNode) method. If you have changed the
class name you should override transformClassName(int, java.lang.String) and return
current class name.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract intDefine current version, that is, the value used when serializing new data.intDefine the supported forward version this migration can read (must be greater or equal thancurrentVersion).abstract com.fasterxml.jackson.databind.JsonNodetransform(int fromVersion, com.fasterxml.jackson.databind.JsonNode json) Implement the transformation of the old JSON structure to the new JSON structure.transformClassName(int fromVersion, String className) Override this method if you have changed the class name.
-
Constructor Details
-
JacksonMigration
public JacksonMigration()
-
-
Method Details
-
currentVersion
public abstract int currentVersion()Define current version, that is, the value used when serializing new data. The first version, when no migration was used, is always 1. -
supportedForwardVersion
public int supportedForwardVersion()Define the supported forward version this migration can read (must be greater or equal thancurrentVersion). If this value is different fromcurrentVersion()aJacksonMigrationmay be required to downcast the received payload to the current schema. -
transform
public abstract com.fasterxml.jackson.databind.JsonNode transform(int fromVersion, com.fasterxml.jackson.databind.JsonNode json) Implement the transformation of the old JSON structure to the new JSON structure. TheJsonNodeis mutable so you can add and remove fields, or change values. Note that you have to cast to specific sub-classes such asObjectNodeandArrayNodeto get access to mutators.- Parameters:
fromVersion- the version of the old datajson- the old JSON data
-
transformClassName
Override this method if you have changed the class name. Return current class name.
-