Class SerializedMessage

java.lang.Object
io.fluxzero.common.api.SerializedMessage
All Implemented Interfaces:
HasMetadata, SerializedObject<byte[]>

public class SerializedMessage extends Object implements SerializedObject<byte[]>, HasMetadata
A serialized message value. Transport codecs own its binary representation; this class owns only message data.
  • Constructor Details

    • SerializedMessage

      public SerializedMessage(Data<byte[]> data, Metadata metadata, String messageId, Long timestamp)
  • Method Details

    • getOriginalRevision

      public int getOriginalRevision()
      Returns the payload revision before any upcasting.
    • data

      public Data<byte[]> data()
      Description copied from interface: SerializedObject
      Returns the serialized payload held by this object.
      Specified by:
      data in interface SerializedObject<byte[]>
      Returns:
      the serialized payload
    • withData

      public SerializedMessage withData(@NonNull @NonNull Data<byte[]> data)
      Description copied from interface: SerializedObject
      Returns a new SerializedObject with the given data object. If the given data is the same instance as the current one, this may be returned.
      Specified by:
      withData in interface SerializedObject<byte[]>
      Parameters:
      data - the new serialized payload
      Returns:
      a new SerializedObject instance. May be this if unchanged
    • getRevision

      public int getRevision()
      Description copied from interface: SerializedObject
      Returns the revision of the serialized object.
      Specified by:
      getRevision in interface SerializedObject<byte[]>
    • getType

      public String getType()
      Description copied from interface: SerializedObject
      Returns the type identifier for the serialized payload.
      Specified by:
      getType in interface SerializedObject<byte[]>
    • getBytes

      public long getBytes()
      Returns the exact size used by the compact binary transports.
    • metadataContainsKey

      public boolean metadataContainsKey(String key)
      Checks a metadata key without forcing callers to handle absent metadata.
    • getMetadataValue

      public String getMetadataValue(String key)
      Returns one metadata value, or null when metadata or the key is absent.
    • getMetadataLongValue

      public long getMetadataLongValue(String key, long defaultValue)
      Returns a decimal metadata value, or the fallback when absent or malformed.
    • encodedMetadataContainsKey

      protected static boolean encodedMetadataContainsKey(byte[] bytes, int offset, int length, String key)
    • encodedMetadataValue

      protected static String encodedMetadataValue(byte[] bytes, int offset, int length, String key)
    • encodedMetadataLongValue

      protected static long encodedMetadataLongValue(byte[] bytes, int offset, int length, String key, long defaultValue)
    • targetEquals

      public boolean targetEquals(String candidate)
      Compares the target without an intermediate optional value.
    • typeEquals

      public boolean typeEquals(String candidate)
      Compares the serialized payload type.