Interface UnknownPropertyHandler
-
- All Known Implementing Classes:
EvolvableHandler
public interface UnknownPropertyHandlerAn interface that defines callbacks that will be called when an unknown properties are encountered during deserialization, as well as to check if there are any unknown properties that should be written out during serialization.The main purpose of this interface is to support schema evolution of objects that use JSON as a long term storage format, without loss of unknown properties across clients and severs using different versions of Java classes.
- Author:
- Aleks Seovic 2018.05.09
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description <T> Consumer<T>readUnknownProperty(String propName, ObjectReader reader, Context ctx)Called whenever a property is encountered in a JSON document that doesn't have a correspondingPropertyMutator.default <T> voidwriteUnknownProperties(T bean, ObjectWriter writer, Context ctx)Write unknown properties encountered during deserialization.
-
-
-
Method Detail
-
readUnknownProperty
<T> Consumer<T> readUnknownProperty(String propName, ObjectReader reader, Context ctx)
Called whenever a property is encountered in a JSON document that doesn't have a correspondingPropertyMutator.Typically, the implementation of this interface concerned with schema evolution will handle this event by storing property value somewhere so it can be written later by the
writeUnknownProperties(T, com.oracle.coherence.io.json.genson.stream.ObjectWriter, com.oracle.coherence.io.json.genson.Context)method.- Parameters:
propName- the name of the unknown propertyreader- the ObjectReader to read property value fromctx- deserialization context- Returns:
- the Consumer that will be called with the target bean, once the target bean is known
-
writeUnknownProperties
default <T> void writeUnknownProperties(T bean, ObjectWriter writer, Context ctx)Write unknown properties encountered during deserialization.This method can be optionally implemented by
UnknownPropertyHandlers that want to write unknown properties during serialization. The default implementation is a no-op.- Parameters:
bean- the object we are serializing into JSONwriter- the ObjectReader to read property value fromctx- serialization context
-
-