Interface ObjectSerializer
public interface ObjectSerializer
Serializer interface for converting between objects and their MessagePack or JSON representations.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final classHolds the lazily-initializedObjectSerializersingleton. -
Method Summary
Modifier and TypeMethodDescription@NotNull com.google.gson.JsonArrayasJsonArray(@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 givenJsonArrayand 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 ObjectSerializertryGet()Returns the lazily-initialized, process-wideObjectSerializersingleton, reflectively loaded from the LiveObjects plugin on the classpath.voidwriteMsgpackArray(@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
Reads a JSON array from the givenJsonArrayand deserializes it into an Object array.- Parameters:
-
json- theJsonArrayrepresenting the array to deserialize - Returns:
- the deserialized Object array
-
asJsonArray
Serializes the given Object array as a JSON array.- Parameters:
-
objects- the Object array to serialize - Returns:
- the resulting JsonArray
-
tryGet
Returns the lazily-initialized, process-wideObjectSerializersingleton, reflectively loaded from the LiveObjects plugin on the classpath. Returnsnullif the plugin is not present; the lookup is retried on subsequent calls until it succeeds.- Returns:
- the shared
ObjectSerializerinstance, ornullif the plugin is unavailable.
-