corda / net.corda.core.serialization

Package net.corda.core.serialization

Supporting data types and classes for serialization of Corda data types.

Types

ClassWhitelist

interface ClassWhitelist

SerializationContext

interface SerializationContext

Parameters to serialization and deserialization.

SerializationDefaults

object SerializationDefaults

Global singletons to be used as defaults that are injected elsewhere (generally, in the node or in RPC client).

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.

SerializationToken

interface SerializationToken

This represents a token in the serialized stream for an instance of a type that implements SerializeAsToken.

SerializationWhitelist

interface SerializationWhitelist

Provide a subclass of this via the java.util.ServiceLoader mechanism to be able to whitelist types for serialisation that you cannot otherwise annotate. The name of the class must appear in a text file on the classpath under the path META-INF/services/net.corda.core.serialization.SerializationWhitelist

SerializeAsToken

interface SerializeAsToken

This interface should be implemented by classes that want to substitute a token representation of themselves if they are serialized because they have a lot of internal state that does not serialize (well).

SerializeAsTokenContext

interface SerializeAsTokenContext

A context for mapping SerializationTokens to/from SerializeAsTokens.

SerializedBytes

class SerializedBytes<T : Any> : OpaqueBytes

A type safe wrapper around a byte array that contains a serialised object. You can call SerializedBytes.deserialize to get the original object back.

SingletonSerializationToken

class SingletonSerializationToken : SerializationToken

A class representing a SerializationToken for some object that is not serializable but can be looked up (when deserialized) via just the class name.

SingletonSerializeAsToken

abstract class SingletonSerializeAsToken : SerializeAsToken

A base class for implementing large objects / components / services that need to serialize themselves to a string token to indicate which instance the token is a serialized form of.

Annotations

CordaSerializable

annotation class CordaSerializable

This annotation is a marker to indicate that a class is permitted and intended to be serialized as part of Node messaging.

DeprecatedConstructorForDeserialization

annotation class DeprecatedConstructorForDeserialization

This annotation is a marker to indicate which secondary constructors should be considered, and in which order, for evolving objects during their deserialisation.

Exceptions

MissingAttachmentsException

class MissingAttachmentsException : CordaException

Thrown during deserialisation to indicate that an attachment needed to construct the WireTransaction is not found.

Extensions for External Classes

kotlin.ByteArray

Functions

deserialize

fun <T : Any> ByteSequence.deserialize(serializationFactory: SerializationFactory = SerializationFactory.defaultFactory, context: SerializationContext = serializationFactory.defaultContext): T

Convenience extension method for deserializing a ByteSequence, utilising the defaults.

fun <T : Any> SerializedBytes<T>.deserialize(serializationFactory: SerializationFactory = SerializationFactory.defaultFactory, context: SerializationContext = serializationFactory.defaultContext): T

Convenience extension method for deserializing SerializedBytes with type matching, utilising the defaults.

serialize

fun <T : Any> T.serialize(serializationFactory: SerializationFactory = SerializationFactory.defaultFactory, context: SerializationContext = serializationFactory.defaultContext): SerializedBytes<T>

Convenience extension method for serializing an object of type T, utilising the defaults.