Interface ObjectSerializer


public interface ObjectSerializer
Serializer interface for converting between objects and their MessagePack or JSON representations.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static final class 
    Holds the lazily-initialized ObjectSerializer singleton.
  • Method Summary

    Modifier and Type
    Method
    Description
    @NotNull com.google.gson.JsonArray
    asJsonArray(@NotNull Object[] objects)
    Serializes the given Object array as a JSON array.
    @NotNull Object[]
    readFromJsonArray(@NotNull com.google.gson.JsonArray json)
    Reads a JSON array from the given JsonArray and deserializes it into an Object array.
    @NotNull Object[]
    readMsgpackArray(@NotNull org.msgpack.core.MessageUnpacker unpacker)
    Reads a MessagePack array from the given unpacker and deserializes it into an Object array.
    static @Nullable ObjectSerializer
    Returns the lazily-initialized, process-wide ObjectSerializer singleton, reflectively loaded from the LiveObjects plugin on the classpath.
    void
    writeMsgpackArray(@NotNull Object[] objects, @NotNull org.msgpack.core.MessagePacker packer)
    Serializes the given Object array as a MessagePack array using the provided packer.
  • Method Details

    • readMsgpackArray

      @NotNull @NotNull Object[] readMsgpackArray(@NotNull @NotNull org.msgpack.core.MessageUnpacker unpacker) throws IOException
      Reads a MessagePack array from the given unpacker and deserializes it into an Object array.
      Parameters:
      unpacker - the MessageUnpacker to read from
      Returns:
      the deserialized Object array
      Throws:
      IOException - if an I/O error occurs during unpacking
    • writeMsgpackArray

      void writeMsgpackArray(@NotNull @NotNull Object[] objects, @NotNull @NotNull org.msgpack.core.MessagePacker packer) throws IOException
      Serializes the given Object array as a MessagePack array using the provided packer.
      Parameters:
      objects - the Object array to serialize
      packer - the MessagePacker to write to
      Throws:
      IOException - if an I/O error occurs during packing
    • readFromJsonArray

      @NotNull @NotNull Object[] readFromJsonArray(@NotNull @NotNull com.google.gson.JsonArray json)
      Reads a JSON array from the given JsonArray and deserializes it into an Object array.
      Parameters:
      json - the JsonArray representing the array to deserialize
      Returns:
      the deserialized Object array
    • asJsonArray

      @NotNull @NotNull com.google.gson.JsonArray asJsonArray(@NotNull @NotNull Object[] objects)
      Serializes the given Object array as a JSON array.
      Parameters:
      objects - the Object array to serialize
      Returns:
      the resulting JsonArray
    • tryGet

      @Nullable static @Nullable ObjectSerializer tryGet()
      Returns the lazily-initialized, process-wide ObjectSerializer singleton, reflectively loaded from the LiveObjects plugin on the classpath. Returns null if the plugin is not present; the lookup is retried on subsequent calls until it succeeds.
      Returns:
      the shared ObjectSerializer instance, or null if the plugin is unavailable.