SerializationFactory - corda

corda / net.corda.core.serialization / SerializationFactory

# SerializationFactory

`abstract class SerializationFactory`

An abstraction for serializing and deserializing objects, with support for versioning of the wire format via a header / prefix in the bytes.

### Constructors

#### <init> | An abstraction for serializing and deserializing objects, with support for versioning of the wire format via a header / prefix in the bytes. `SerializationFactory()`

### Properties

#### currentContext | 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. `val currentContext: SerializationContext?`
#### defaultContext | 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). `val defaultContext: SerializationContext`

### Functions

#### asCurrent | 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. `fun <T> asCurrent(block: SerializationFactory.() -> T): T`
#### deserialize | Deserialize the bytes in to an object, using the prefixed bytes to determine the format. `abstract fun <T : Any> deserialize(byteSequence: ByteSequence, clazz: Class<T>, context: SerializationContext): T`
#### deserializeWithCompatibleContext | Deserialize the bytes in to an object, using the prefixed bytes to determine the format. `abstract fun <T : Any> deserializeWithCompatibleContext(byteSequence: ByteSequence, clazz: Class<T>, context: SerializationContext): ObjectWithCompatibleContext<T>`
#### serialize | Serialize an object to bytes using the preferred serialization format version from the context. `abstract fun <T : Any> serialize(obj: T, context: SerializationContext): SerializedBytes<T>`
#### withCurrentContext | Change the current context inside the block to that supplied. `fun <T> withCurrentContext(context: SerializationContext?, block: () -> T): T`

### Companion Object Properties

#### currentFactory | If there is a need to nest serialization/deserialization with a modified context during serialization or deserialization, this will return the current factory used to start serialization/deserialization. `val currentFactory: SerializationFactory?`
#### defaultFactory | A default factory for serialization/deserialization, taking into account the currentFactory if set. `val defaultFactory: SerializationFactory`