Class WicaChannelDataSerializer

java.lang.Object
ch.psi.wica.infrastructure.channel.WicaChannelDataSerializer

@Immutable public class WicaChannelDataSerializer extends Object
Supports serialization of objects of type WicaChannelData and its children, including WicaChannelMetadata and WicaChannelValue.
  • Constructor Details

    • WicaChannelDataSerializer

      WicaChannelDataSerializer(Set<String> fieldsOfInterest, int numericScale, boolean quoteNumericStrings)
      Returns an instance that will serialize SELECTED @JsonProperty annotated fields in a ChannelData object, or any of its children.

      In cases where the underlying type of the annotated field is double then the value will be serialized with the specified numeric scale (= number of digits after the decimal point).

      Special double values such a Nan and Infinity will be written as either numbers or strings depending on the quoteNumericStrings setting.

      For strict JSON compliance string format should be selected, although this may imply extra work on the decoding end to reconstruct the original types. For JSON5 compliance number format can be selected.

      Parameters:
      fieldsOfInterest - specifies the fields that are to be serialised according to the @JsonProperty annotations in the ChannelDataObject.
      numericScale - a non-negative number specifying the number of digits to appear after the decimal point in the serialized representation.
      quoteNumericStrings - - determines whether the special double values NaN and Infinity will be serialised as numbers or strings.
      Throws:
      IllegalArgumentException - if the numericScale was negative.
      NullPointerException - if the supplied filterProvider was null.
  • Method Details

    • writeToJson

      public String writeToJson(WicaChannelData wicaChannelData)
      Serializes the supplied WicaChannelData object according to the configuration rules specified in the class constructor.
      Parameters:
      wicaChannelData - the object to serialize.
      Returns:
      the JSON serialized representation.