Class SerializeUtils

java.lang.Object
google.registry.util.SerializeUtils

public final class SerializeUtils extends Object
Utilities for easy serialization with informative error messages.
  • Method Details

    • serialize

      @Nullable public static byte[] serialize(@Nullable Object value)
      Turns an object into a byte array.
      Returns:
      serialized object or null if value is null
    • deserialize

      @Nullable public static <T> T deserialize(Class<T> type, @Nullable byte[] objectBytes)
      Turns a byte string into an object.
      Returns:
      deserialized object or null if objectBytes is null
    • serializeDeserialize

      public static Object serializeDeserialize(Object object)
      Serializes an object then deserializes it. This is typically used in tests.
    • encodeBase64

      public static String encodeBase64(byte[] bytes)
      Encodes a byte array as a URL-safe string.
    • decodeBase64

      public static byte[] decodeBase64(String objectString)
      Turns a string encoded by encodeBase64(byte[]) back into a byte array.
    • stringify

      public static String stringify(Serializable object)
      Turns an object into an encoded string that can be used safely as a URI query parameter.
    • parse

      @Nullable public static <T> T parse(Class<T> type, String objectString)
      Turns a string encoded by stringify() into an object.