Class StatusMessageSerializer

java.lang.Object
de.iip_ecosphere.platform.transport.status.StatusMessageSerializer
All Implemented Interfaces:
InputTypeTranslator<byte[],StatusMessage>, OutputTypeTranslator<StatusMessage,byte[]>, Serializer<StatusMessage>, TypeTranslator<StatusMessage,byte[]>

public class StatusMessageSerializer extends Object implements Serializer<StatusMessage>
A simple, generic status serializer. Additional enum constants must be registered here.
Author:
Holger Eichelberger, SSE
  • Field Details

    • ACTION_CONSTANTS

      private static final Map<String,ActionType> ACTION_CONSTANTS
    • COMPONENT_CONSTANTS

      private static final Map<String,ComponentType> COMPONENT_CONSTANTS
    • MAPPER

      private static final de.iip_ecosphere.platform.support.json.Json MAPPER
  • Constructor Details

    • StatusMessageSerializer

      public StatusMessageSerializer()
  • Method Details

    • createTypeTranslator

      public static TypeTranslator<StatusMessage,String> createTypeTranslator()
      Creates a type translator based on the serialization approach in this class.
      Returns:
      the type translator
    • registerActions

      public static void registerActions(Class<? extends ActionType> type)
      Registers custom action types. Already registered types will not be overridden. Registration follows enum constant conventions, i.e., only static final public values of the given type declared in that type will be considered.
      Parameters:
      type - the type to register
    • registerComponents

      public static void registerComponents(Class<? extends ComponentType> type)
      Registers custom component types. Already registered types will not be overridden. Registration follows enum constant conventions, i.e., only static final public values of the given type declared in that type will be considered.
      Parameters:
      type - the type to register
    • register

      private static <T> void register(Class<? extends T> cls, Map<String,T> mapping)
      Does the registration of cls as enum constant and modifies mapping as side effect.
      Type Parameters:
      T - the "enum" type
      Parameters:
      cls - the type
      mapping - the mapping to be modified as side effect
    • from

      public StatusMessage from(byte[] data) throws IOException
      Description copied from interface: InputTypeTranslator
      Deserializes a target value into a source value ("input from external").
      Specified by:
      from in interface InputTypeTranslator<byte[],StatusMessage>
      Parameters:
      data - the data to be translated back
      Returns:
      the serialized object
      Throws:
      IOException - in case that serialization fails
    • to

      public byte[] to(StatusMessage source) throws IOException
      Description copied from interface: OutputTypeTranslator
      Translates a source value into a target value ("output to external").
      Specified by:
      to in interface OutputTypeTranslator<StatusMessage,byte[]>
      Parameters:
      source - the source value to be translated
      Returns:
      the target value
      Throws:
      IOException - in case that translation fails
    • clone

      public StatusMessage clone(StatusMessage origin) throws IOException
      Description copied from interface: Serializer
      Creates a new value instance and copies the values from origin to the new instance. Use the SerializerRegistry to implement cloning of nested object values.
      Specified by:
      clone in interface Serializer<StatusMessage>
      Parameters:
      origin - the object to clone
      Returns:
      the cloned object
      Throws:
      IOException - in case that cloning/serialization operations fail
    • getType

      public Class<StatusMessage> getType()
      Description copied from interface: Serializer
      The type to be handled by this serializer.
      Specified by:
      getType in interface Serializer<StatusMessage>
      Returns:
      the type