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 EMessageObject.Builder<M extends EMessageObject,B extends EMessageObject.Builder<M,?>> extends Object
EMessageObject builders. Used
by eBus when de-serializing an encoded message back into
the target message object.| Modifier and Type | Field and Description |
|---|---|
protected Class<? extends EMessageObject> |
mTargetClass
Message class instance returned by
build(). |
| Modifier | Constructor and Description |
|---|---|
protected |
Builder(Class<? extends EMessageObject> targetClass) |
| Modifier and Type | Method and Description |
|---|---|
M |
build()
Returns the target message instance constructed from
the configured properties.
|
protected abstract M |
buildImpl()
Returns eBus message instance built from the
configured properties.
|
protected void |
validate(List<String> problems)
Checks if message subject and message type are
configured.
|
protected final Class<? extends EMessageObject> mTargetClass
build().
This value is used to identify the target class when
a build failure occurs, placed into the
ValidationException.protected Builder(Class<? extends EMessageObject> targetClass)
protected abstract M buildImpl()
validated prior to calling
this method. The message object may now be
constructed.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.
problems - append validation problems to this
list.public final M build() throws ValidationException
ValidationException - if this builder does not contain a valid
target message configuration. This exception contains
a list of all validation problems found.Copyright © 2019. All rights reserved.