Package io.hekate.messaging
Class MessageMetaData
- java.lang.Object
-
- io.hekate.messaging.MessageMetaData
-
public class MessageMetaData extends Object
Message meta-data.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MessageMetaData.Key<T>
Key of aMessageMetaData
's attribute.static interface
MessageMetaData.MetaDataCodec<T>
Codec forMessageMetaData
values.
-
Constructor Summary
Constructors Constructor Description MessageMetaData()
Constructs a new instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> T
get(MessageMetaData.Key<T> key)
Returns the value of the specified key.boolean
isEmpty()
Returnstrue
if this instance doesn't hold any key/value pairs.static MessageMetaData
readFrom(DataReader in)
Reads aMessageMetaData
from the specified reader.<T> void
set(MessageMetaData.Key<T> key, T value)
Sets the key/value pair.int
size()
Returns the amount of key/value pairs of this instance.String
toString()
void
writeTo(DataWriter out)
Writes the content of this instance into the specified writer.
-
-
-
Method Detail
-
readFrom
public static MessageMetaData readFrom(DataReader in) throws IOException
Reads aMessageMetaData
from the specified reader.- Parameters:
in
- Reader.- Returns:
- An instance if
MessageMetaData
that was decoded from the reader. - Throws:
IOException
- if failed to read data.
-
writeTo
public void writeTo(DataWriter out) throws IOException
Writes the content of this instance into the specified writer.- Parameters:
out
- Writer.- Throws:
IOException
- if failed to write data.- See Also:
readFrom(DataReader)
-
get
public <T> T get(MessageMetaData.Key<T> key)
Returns the value of the specified key. Returnsnull
if such key doesn't exist.- Type Parameters:
T
- Value type.- Parameters:
key
- Key.- Returns:
- Value for the specified key or
null
.
-
set
public <T> void set(MessageMetaData.Key<T> key, T value)
Sets the key/value pair. If key already exists then its value will be overwritten.- Type Parameters:
T
- Value type.- Parameters:
key
- Key.value
- Value.
-
size
public int size()
Returns the amount of key/value pairs of this instance.- Returns:
- Amount of key/value pairs of this instance.
-
isEmpty
public boolean isEmpty()
Returnstrue
if this instance doesn't hold any key/value pairs.- Returns:
true
if this instance doesn't hold any key/value pairs.
-
-