Class TableUpdater<S>
- Type Parameters:
S
- The type of each row in the table updated by this updater.
Concrete subclasses should be public static inner classes of the view they update a table for. A public no-parameter constructor must exist and is used to create instances used.
For a single table view the table name can be inferred from queries, but for a multi table view each class must
be annotated with Table
identifying which table they update.
Concrete class must be annotated with one of the Consume
annotations.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
An UpdateEffect is a description of what the runtime needs to do after the command is handled. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected final TableUpdater.Effect.Builder
<S> effects()
emptyRow()
The default implementation of this method returnsnull
.protected final S
rowState()
Returns the current state of the row for the subject that is being updated.protected final UpdateContext
Additional context and metadata for an update handler.
-
Constructor Details
-
TableUpdater
public TableUpdater()
-
-
Method Details
-
updateContext
Additional context and metadata for an update handler.It will throw an exception if accessed from constructor.
-
rowState
Returns the current state of the row for the subject that is being updated.Note that modifying the row object directly will not update it in storage. To save the row, one must call {
effects().updateRow()
}.This method can only be called when handling an update. Calling it outside a method (eg: in the constructor) will raise a IllegalStateException exception.
- Throws:
IllegalStateException
- if accessed outside a handler method
-
effects
-
emptyRow
The default implementation of this method returnsnull
. It can be overridden to return a more sensible initial state.- Returns:
- an empty row object or
null
to hand to the process method when an event for a previously unknown subject id is seen.
-