Class TraceRecordSerializer

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

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

  • Constructor Details

    • TraceRecordSerializer

      public TraceRecordSerializer()
  • Method Details

    • getFilter

      public static TraceRecordFilter getFilter()
      Returns the trace record filter.
      Returns:
      the filter
    • createMapper

      private static de.iip_ecosphere.platform.support.json.Json createMapper()
      Creates a specific object mapper that allows for lazy default serialization of unknown types as it is the case for the payload in TraceRecord.
      Returns:
      the object mapper
    • createTypeTranslator

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

      public TraceRecord 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[],TraceRecord>
      Parameters:
      data - the data to be translated back
      Returns:
      the serialized object
      Throws:
      IOException - in case that serialization fails
    • to

      public byte[] to(TraceRecord 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<TraceRecord,byte[]>
      Parameters:
      source - the source value to be translated
      Returns:
      the target value
      Throws:
      IOException - in case that translation fails
    • clone

      public TraceRecord clone(TraceRecord 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<TraceRecord>
      Parameters:
      origin - the object to clone
      Returns:
      the cloned object
      Throws:
      IOException - in case that cloning/serialization operations fail
    • getType

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

      public static void ignoreClass(Class<?> cls)
      Registers a type to be ignored when serializing trace record (payloads).
      Parameters:
      cls - the class representing the type to be ignored
    • ignoreField

      public static void ignoreField(Class<?> cls, String field)
      Registers a field to be ignored when serializing trace record (payloads).
      Parameters:
      cls - the class representing the type containing the field
      field - the field to be ignored
    • ignoreFields

      public static void ignoreFields(Class<?> cls, String... fields)
      Registers fields to be ignored when serializing trace record (payloads).
      Parameters:
      cls - the class representing the type containing the field
      fields - the fields to be ignored
      See Also:
    • clearIgnores

      public static void clearIgnores()
      Clears all ignored types and fields.