Class OptionalSerializer

java.lang.Object
com.esotericsoftware.kryo.Serializer<Optional<?>>
uno.anahata.ai.internal.kryo.OptionalSerializer

public class OptionalSerializer extends com.esotericsoftware.kryo.Serializer<Optional<?>>
A custom Kryo serializer for Optional.

Standard Java serialization does not support Optional, and Kryo's default JavaSerializer relies on it. This serializer handles Optional by writing a boolean to indicate if a value is present, followed by the value itself if it exists.

Author:
Anahata
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new OptionalSerializer and marks it as immutable.
  • Method Summary

    Modifier and Type
    Method
    Description
    read(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Input input, Class<? extends Optional<?>> type)
     
    void
    write(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Output output, Optional<?> object)
     

    Methods inherited from class com.esotericsoftware.kryo.Serializer

    copy, getAcceptsNull, isImmutable, setAcceptsNull, setImmutable

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • OptionalSerializer

      public OptionalSerializer()
      Constructs a new OptionalSerializer and marks it as immutable.
  • Method Details

    • write

      public void write(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Output output, Optional<?> object)
      Specified by:
      write in class com.esotericsoftware.kryo.Serializer<Optional<?>>
    • read

      public Optional<?> read(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Input input, Class<? extends Optional<?>> type)
      Specified by:
      read in class com.esotericsoftware.kryo.Serializer<Optional<?>>