Class SerializeContainer

java.lang.Object
de.eldoria.eldoutilities.serialization.wrapper.SerializeContainer

public class SerializeContainer extends Object
  • Method Details

    • fromObject

      public static SerializeContainer fromObject(ConfigurationSerializable obj)
      Create a container from a serializable object.
      Parameters:
      obj - onbect to serialize
      Returns:
      container holding the object as a map.
    • fromJson

      public static SerializeContainer fromJson(String json)
      Create a container from a map which was serialized previously
      Parameters:
      json - json string
      Returns:
      container holding the string as a map
    • serializeToJson

      public static String serializeToJson(ConfigurationSerializable obj)
      Convert a serializable object to a json string
      Parameters:
      obj - object to serialize
      Returns:
      object as string
    • deserializeFromJson

      public static <T extends ConfigurationSerializable> T deserializeFromJson(String json, Class<T> clazz)
      Convert a json serialized object to a new object instance
      Type Parameters:
      T - type to return
      Parameters:
      json - json to convert
      clazz - clazz to determine the return type
      Returns:
      a new instance of the serialzied object.
    • toObject

      public <T extends ConfigurationSerializable> T toObject(Class<T> clazz)
      Converts the underlying map to the object
      Type Parameters:
      T - type to return
      Parameters:
      clazz - clazz to determine the return type
      Returns:
      a new instance of the serialzied object.
    • toJson

      public String toJson()
      Conversts the underlying map to a json string
      Returns:
      map as json string