Package kalix.javasdk
Class JsonMigration
Object
kalix.javasdk.JsonMigration
Allows to specify dedicated strategy for JSON schema evolution.
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 add it to supportedClassNames()
.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract int
Define current version, that is, the value used when serializing new data.Override this method if you have changed the class name.int
Define the supported forward version this migration can read (must be greater or equal than `currentVersion`).com.fasterxml.jackson.databind.JsonNode
transform
(int fromVersion, com.fasterxml.jackson.databind.JsonNode json) Implement the transformation of the incoming JSON structure to the current JSON structure.
-
Constructor Details
-
JsonMigration
public JsonMigration()
-
-
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 0. -
supportedForwardVersion
public int supportedForwardVersion()Define the supported forward version this migration can read (must be greater or equal than `currentVersion`). If this value is different fromcurrentVersion()
atransform(int, com.fasterxml.jackson.databind.JsonNode)
will be used to downcast the received payload to the current schema. -
transform
public com.fasterxml.jackson.databind.JsonNode transform(int fromVersion, com.fasterxml.jackson.databind.JsonNode json) Implement the transformation of the incoming JSON structure to the current JSON structure. The `JsonNode` is mutable so you can add and remove fields, or change values. Note that you have to cast to specific sub-classes such as `ObjectNode` and `ArrayNode` to get access to mutators.- Parameters:
fromVersion
- the version of the old datajson
- the incoming JSON data
-
supportedClassNames
Override this method if you have changed the class name. Return all old class names.
-