M - builds this target message class.B - message builder subclass. Needed to return the
correct builder type when setting fields. If this were not
the case, field chaining would not work.public abstract static class EMessage.Builder<M extends EMessage,B extends EMessage.Builder<M,?>> extends EMessageObject.Builder<M,B>
EMessage builders. Used by
eBus when de-serializing an encoded message back into the
target message object.mTargetClass| Modifier | Constructor and Description |
|---|---|
protected |
Builder(Class<? extends EMessageObject> targetClass,
EMessage.MessageType type)
Creates an eBus message builder instance.
|
protected |
Builder(Class<? extends EMessageObject> targetClass,
String subject,
EMessage.MessageType type)
Creates an eBus message builder instance for the given
message subject.
|
protected |
Builder(Class<? extends EMessageObject> targetClass,
String subject,
long timestamp,
EMessage.MessageType type)
Creates an eBus message builder instance for the given
message subject and timestamp.
|
| Modifier and Type | Method and Description |
|---|---|
B |
subject(String subject)
Sets the message subject to the given value.
|
B |
timestamp(Instant ts)
Sets the message timestamp to the given value.
|
B |
timestamp(long ts)
Sets the message timestamp to the given value.
|
protected void |
validate(List<String> problems)
Checks if message subject and message type are
configured.
|
build, buildImplprotected Builder(Class<? extends EMessageObject> targetClass, EMessage.MessageType type)
targetClass - builds this message class.type - notification, request, or reply message.protected Builder(Class<? extends EMessageObject> targetClass, String subject, EMessage.MessageType type)
targetClass - builds this message class.subject - message subject.type - notification, request, or reply message.protected Builder(Class<? extends EMessageObject> targetClass, String subject, long timestamp, EMessage.MessageType type)
timestamp - message create timestamp.subject - message subject.targetClass - builds this message class.type - notification, request, or reply message.protected void validate(List<String> problems)
problems.
This method should be overridden by subclass message
builders and called before doing its own
validation. The first line in the subclass
validate implementation should be
super.validate(problems);.
When overriding this method, be sure to add all
discovered validation problems to the list. The
validation method should consist of a series of
individual if statements and not
an if/else if chain. That way all problems
are found and not just the first one.
validate in class EMessageObject.Builder<M extends EMessage,B extends EMessage.Builder<M,?>>problems - append validation problems to this
list.public final B subject(String subject)
this builder so that field
configuration may be chained.subject - message subject.this builder instance.IllegalArgumentException - if subject is either null or
empty.public final B timestamp(long ts)
this builder so that field
configuration may be chained.ts - message timestamp.this builder instance.Copyright © 2019. All rights reserved.