Package org.drasyl.remote.protocol
Class MessageId
- java.lang.Object
-
- org.drasyl.remote.protocol.MessageId
-
public final class MessageId extends Object
AAddressedEnvelopeis uniquely identified by itsMESSAGE_ID_LENGTHbytes identifier.This is an immutable object.
-
-
Field Summary
Fields Modifier and Type Field Description static intMESSAGE_ID_LENGTH
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]byteArrayValue()booleanequals(Object o)inthashCode()static booleanisValidMessageId(byte[] id)Checks ifidis a valid identifier.longlongValue()static MessageIdof(byte[] id)static MessageIdof(long id)static MessageIdof(String id)static MessageIdrandomMessageId()Static factory to retrieve a randomly generatedMessageId.StringtoString()
-
-
-
Field Detail
-
MESSAGE_ID_LENGTH
public static final int MESSAGE_ID_LENGTH
- See Also:
- Constant Field Values
-
-
Method Detail
-
byteArrayValue
public byte[] byteArrayValue()
-
longValue
public long longValue()
-
randomMessageId
public static MessageId randomMessageId()
Static factory to retrieve a randomly generatedMessageId.- Returns:
- A randomly generated
MessageId
-
isValidMessageId
public static boolean isValidMessageId(byte[] id)
Checks ifidis a valid identifier.- Parameters:
id- string to be validated- Returns:
trueif valid. Otherwisefalse
-
of
public static MessageId of(@NonNull byte[] id)
- Throws:
NullPointerException- ifidisnull
-
of
public static MessageId of(@NonNull String id)
- Throws:
NullPointerException- ifidisnull
-
of
public static MessageId of(long id)
-
-