Class SerializationUtil

java.lang.Object
de.eldoria.eldoutilities.serialization.SerializationUtil

public final class SerializationUtil extends Object
Class which provides utilities for serialization and deserialization.
Since:
1.0.0
  • Method Details

    • newBuilder

      public static SerializationUtil.Builder newBuilder()
      Creates a new serialization map builder.
      Returns:
      builder for serialization
    • newBuilder

      public static SerializationUtil.Builder newBuilder(Map<String,Object> map)
      Creates a new serialization map builder based on a map.
      Parameters:
      map - map which should be used to append the new values
      Returns:
      builder for serialization
    • keyToString

      public static <T, U> BiFunction<T,U,String> keyToString()
    • valueOnly

      public static <T, U> BiFunction<T,U,Object> valueOnly(Function<U,?> valueFunction)
    • keyToPrefixedString

      public static <T, U> BiFunction<T,U,String> keyToPrefixedString(String prefix)
    • mapOf

      public static TypeResolvingMap mapOf(Map<String,Object> serialized)
      Creates a new type resolving map from a map.
      Parameters:
      serialized - object as map
      Returns:
      type resolving map
    • objectToMap

      public static Map<String,Object> objectToMap(Object obj)
      Converts an Object to a Map.

      This is done by retrieving all fields which are not marked as transient. This will include fields which are defined by a inherited class as well.

      the variable names are used as keys.

      Parameters:
      obj - object to map
      Returns:
      object as map
      Since:
      1.1.0
    • mapOnObject

      public static <T> void mapOnObject(Map<String,Object> objectMap, T obj)
      Maps objects from a map on an object.

      Only fields which are not mapped as transient will be mapped.

      Fields are identified by their name. Fields are only set when a key is present in the map.

      Type Parameters:
      T - type of object
      Parameters:
      objectMap - mappings of object content
      obj - object to map the objects from map
      Since:
      1.1.0