public abstract class EMessage extends EMessageObject implements java.io.Serializable
EMessage
is the base class for all eBus messages and
contains the message subject and timestamp.
Application messages do not extend this class
directly but one of the subclasses:
ENotificationMessage
, ERequestMessage
, or
EReplyMessage
.
Note: messages are limited to 31 fields. This
is due to eBus binary serialization format. This number is
decreased to 29 fields for sub-classes because
EMessage
used two fields: subject
and
timestamp
. The work-around to this limitation is to
group fields into an EField
subclass, which is allowed
to have 31 fields of its own. So if a message class uses two
EField
subclasses, it may contain up to 62 fields with
31 in each field subclass.
Note: a EMessage
subclass may
be used as a message field itself. That means
that a message may contain another message as a field.
This class is immutable.
See EMessageObject
for detailed explanation of the
required builder inner class.
EMessageHeader
,
EMessageObject
,
ENotificationMessage
,
ERequestMessage
,
EReplyMessage
,
EField
,
Serialized FormModifier and Type | Class and Description |
---|---|
static class |
EMessage.Builder<M extends EMessage,B extends EMessage.Builder<M,?>>
Base class for all
EMessage builders. |
static class |
EMessage.MessageType
Messages are divided into four types: notification,
request, reply and system.
|
Modifier and Type | Field and Description |
---|---|
static int |
MAX_SUBJECT_LENGTH
eBus subjects are restricted to 512 characters.
|
java.lang.String |
subject
The required message subject.
|
long |
timestamp
The message timestamp in Java millisecond epoch time.
|
Modifier | Constructor and Description |
---|---|
protected |
EMessage(EMessage.Builder<?,?> builder)
Creates a new eBus message based on the given message
builder.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object o)
Returns
true if o is a
non-null EMessage instance with a subject and
timestamp equal to this EMessage instance and
false otherwise. |
int |
hashCode()
Returns the message header hash code.
|
boolean |
isApplicationMessage()
Returns
true if this is an application
message and false otherwise. |
boolean |
isSystemMessage()
Returns
true if this is a system message and
false otherwise. |
EMessageKey |
key()
Returns the unique message key based on the message class
and subject.
|
EMessage.MessageType |
messageType()
Returns the
message type . |
java.lang.String |
toString()
Returns message subject and timestamp as a string.
|
public static final int MAX_SUBJECT_LENGTH
public final java.lang.String subject
public final long timestamp
protected EMessage(EMessage.Builder<?,?> builder)
builder
is guaranteed to contain a valid
message configuration at this point.builder
- contains the eBus message configuration.public boolean equals(java.lang.Object o)
true
if o
is a
non-null EMessage
instance with a subject and
timestamp equal to this EMessage
instance and
false
otherwise.equals
in class java.lang.Object
o
- comparison object.true
if the message fields are equal
and false
otherwise.public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public EMessageKey key()
public EMessage.MessageType messageType()
message type
.public boolean isSystemMessage()
true
if this is a system message and
false
otherwise. Only eBus is allowed to transmit
a system message.true
if this is a system message and
false
otherwise.public boolean isApplicationMessage()
true
if this is an application
message and false
otherwise.true
if this is an application
message and false
otherwise.Copyright © 2001 - 2024. Charles W. Rapp. All rights reserved.