TranslatedSchema

class TranslatedSchema<T : Any, U : Any>(val baseSchema: FateSchema<U>, val toBase: (T) -> U) : FateSchema<T>

A schema for converting objects of type T to another type U during serialization.

Parameters

baseSchema

The schema for the base type T

toBase

A function that converts objects of type T to objects of type U

Constructors

Link copied to clipboard
constructor(baseClass: Class<U>, toBase: (T) -> U)

Creates a new TranslatedSchema with the specified configuration.

constructor(baseSchema: FateSchema<U>, toBase: (T) -> U)

Properties

Link copied to clipboard
Link copied to clipboard
open override val schema: ByteArray

The complete schema definition as a byte array.

Link copied to clipboard
open override val schemaSize: Int

Number of bytes required to encode this schema's metadata.

Link copied to clipboard
open override val tag: Int

Unique identifier for this schema type within the FateWeaver format.

Link copied to clipboard
val toBase: (T) -> U

Functions

Link copied to clipboard
open override fun encodeObject(buffer: ByteBuffer, obj: T)

Encodes the given object into the provided buffer.

Link copied to clipboard
open fun encodeSchema(buffer: ByteBuffer)

Encodes this schema's metadata into the provided buffer.

Link copied to clipboard
open override fun objSize(obj: T): Int

Calculates the number of bytes required to encode the given object.