EnumSchema

class EnumSchema<T : Enum<T>>(val enumClass: Class<out Enum<T>>) : FateSchema<T>

Encodes an enum constant as its 4-byte ordinal.

The schema lists the constant names, so a reader can show names instead of ordinals. The value type is T, not Enum<T>, so a channel is a LogChannel<MyEnum> and the schema works as a map key or array element.

Constructors

Link copied to clipboard
constructor(enumClass: Class<out Enum<T>>)

Properties

Link copied to clipboard
val enumClass: Class<out Enum<T>>
Link copied to clipboard
open override val schema: ByteArray

The schema definition as bytes, which the writer puts in the log.

Link copied to clipboard
open override val schemaSize: Int

Number of bytes in this schema's definition.

Link copied to clipboard
open override val tag: Int

The integer that identifies this schema's type in the log.

Functions

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

Writes the given object into the buffer.

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

Writes the whole schema definition, starting with the tag, into the buffer.

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

Returns the number of bytes encodeObject writes for the given object.