public class SerializationFactory
An abstraction for serializing and deserializing objects, with support for versioning of the wire format via a header / prefix in the bytes.
public static net.corda.core.serialization.SerializationFactory.Companion Companion
public SerializationFactory()
An abstraction for serializing and deserializing objects, with support for versioning of the wire format via a header / prefix in the bytes.
@NotNull public <T> T deserialize(@NotNull ByteSequence byteSequence, @NotNull java.lang.Class<T> clazz, @NotNull SerializationContext context)
Deserialize the bytes in to an object, using the prefixed bytes to determine the format.
@NotNull public <T> ObjectWithCompatibleContext<T> deserializeWithCompatibleContext(@NotNull ByteSequence byteSequence, @NotNull java.lang.Class<T> clazz, @NotNull SerializationContext context)
Deserialize the bytes in to an object, using the prefixed bytes to determine the format.
byteSequence
- The bytes to deserialize, including a format header prefix.clazz
- The class or superclass or the object to be deserialized, or Any or Object if unknown.context
- A context that configures various parameters to deserialization.interface SerializationContext
to identify encoding used.@NotNull public <T> SerializedBytes<T> serialize(@NotNull T obj, @NotNull SerializationContext context)
Serialize an object to bytes using the preferred serialization format version from the context.
obj
- The object to be serialized.context
- A context that configures various parameters to serialization, including the serialization format version.@Nullable public SerializationContext getCurrentContext()
If there is a need to nest serialization/deserialization with a modified context during serialization or deserialization, this will return the current context used to start serialization/deserialization.
@NotNull public SerializationContext getDefaultContext()
A context to use as a default if you do not require a specially configured context. It will be the current context
if the use is somehow nested (see currentContext
).
currentContext
public <T> T withCurrentContext(@Nullable SerializationContext context, @NotNull kotlin.jvm.functions.Function0<? extends T> block)
Change the current context inside the block to that supplied.
public <T> T asCurrent(@NotNull kotlin.jvm.functions.Function1<? super net.corda.core.serialization.SerializationFactory,? extends T> block)
Allow subclasses to temporarily mark themselves as the current factory for the current thread during serialization/deserialization. Will restore the prior context on exiting the block.