Class SerializedMessage
java.lang.Object
io.fluxzero.common.api.SerializedMessage
- All Implemented Interfaces:
HasMetadata, SerializedObject<byte[]>
A serialized message value. Transport codecs own its binary representation; this class owns only message data.
-
Field Summary
Fields inherited from interface HasMetadata
CHUNK_INDEX, FINAL_CHUNK, FIRST_CHUNK -
Constructor Summary
ConstructorsConstructorDescriptionSerializedMessage(Data<byte[]> data, Metadata metadata, String messageId, Long timestamp) -
Method Summary
Modifier and TypeMethodDescriptionData<byte[]> data()Returns the serialized payload held by this object.protected static booleanencodedMetadataContainsKey(byte[] bytes, int offset, int length, String key) protected static longencodedMetadataLongValue(byte[] bytes, int offset, int length, String key, long defaultValue) protected static StringencodedMetadataValue(byte[] bytes, int offset, int length, String key) longgetBytes()Returns the exact size used by the compact binary transports.longgetMetadataLongValue(String key, long defaultValue) Returns a decimal metadata value, or the fallback when absent or malformed.getMetadataValue(String key) Returns one metadata value, ornullwhen metadata or the key is absent.intReturns the payload revision before any upcasting.intReturns the revision of the serialized object.getType()Returns the type identifier for the serialized payload.booleanChecks a metadata key without forcing callers to handle absent metadata.booleantargetEquals(String candidate) Compares the target without an intermediate optional value.booleantypeEquals(String candidate) Compares the serialized payload type.Returns a newSerializedObjectwith the given data object.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface HasMetadata
chunked, firstChunk, getMetadata, lastChunk
-
Constructor Details
-
SerializedMessage
-
-
Method Details
-
getOriginalRevision
public int getOriginalRevision()Returns the payload revision before any upcasting. -
data
Description copied from interface:SerializedObjectReturns the serialized payload held by this object.- Specified by:
datain interfaceSerializedObject<byte[]>- Returns:
- the serialized payload
-
withData
Description copied from interface:SerializedObjectReturns a newSerializedObjectwith the given data object. If the given data is the same instance as the current one,thismay be returned.- Specified by:
withDatain interfaceSerializedObject<byte[]>- Parameters:
data- the new serialized payload- Returns:
- a new
SerializedObjectinstance. May bethisif unchanged
-
getRevision
public int getRevision()Description copied from interface:SerializedObjectReturns the revision of the serialized object.- Specified by:
getRevisionin interfaceSerializedObject<byte[]>
-
getType
Description copied from interface:SerializedObjectReturns the type identifier for the serialized payload.- Specified by:
getTypein interfaceSerializedObject<byte[]>
-
getBytes
public long getBytes()Returns the exact size used by the compact binary transports. -
metadataContainsKey
Checks a metadata key without forcing callers to handle absent metadata. -
getMetadataValue
-
getMetadataLongValue
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
-
encodedMetadataLongValue
protected static long encodedMetadataLongValue(byte[] bytes, int offset, int length, String key, long defaultValue) -
targetEquals
Compares the target without an intermediate optional value. -
typeEquals
Compares the serialized payload type.
-