Package org.drasyl.remote.protocol
Class MessageId
- java.lang.Object
-
- org.drasyl.remote.protocol.MessageId
-
public final class MessageId extends Object
AAddressedEnvelope
is uniquely identified by itsMESSAGE_ID_LENGTH
bytes identifier.This is an immutable object.
-
-
Field Summary
Fields Modifier and Type Field Description static int
MESSAGE_ID_LENGTH
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]
byteArrayValue()
boolean
equals(Object o)
int
hashCode()
static boolean
isValidMessageId(byte[] id)
Checks ifid
is a valid identifier.long
longValue()
static MessageId
of(byte[] id)
static MessageId
of(long id)
static MessageId
of(String id)
static MessageId
randomMessageId()
Static factory to retrieve a randomly generatedMessageId
.String
toString()
-
-
-
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 ifid
is a valid identifier.- Parameters:
id
- string to be validated- Returns:
true
if valid. Otherwisefalse
-
of
public static MessageId of(@NonNull byte[] id)
- Throws:
NullPointerException
- ifid
isnull
-
of
public static MessageId of(@NonNull String id)
- Throws:
NullPointerException
- ifid
isnull
-
of
public static MessageId of(long id)
-
-