I
- the type of the entity IDs to which the updates are routedpublic final class StateUpdateRouting<I>
extends java.lang.Object
A routing schema consists of a default route and custom routes per entity state class.
When calculating targets to be notified on the updated state, StateUpdateRouting
would
see if there is a custom route set for the type of the entity state.
If not found, the default route will be
applied.
Modifier and Type | Method and Description |
---|---|
R |
apply(M message,
C context)
Obtains IDs of entities to which the passed message should be delivered.
|
protected Route<M,C,R> |
defaultRoute()
Obtains the default route used by the schema.
|
static <I> StateUpdateRouting<I> |
newInstance(java.lang.Class<I> idClass)
Creates a new
StateUpdateRouting . |
void |
remove(java.lang.Class<? extends M> messageClass)
Removes a route for the passed message class.
|
<S extends io.spine.base.EntityState> |
route(java.lang.Class<S> stateClass,
StateUpdateRoute<I,S> via)
Sets a custom route for the passed entity state class.
|
boolean |
supports(java.lang.Class<? extends io.spine.base.EntityState> stateType)
Verifies if the passed state type can be routed by a custom route, or
the message has a field matching the type of identifiers served by this routing.
|
public static <I> StateUpdateRouting<I> newInstance(java.lang.Class<I> idClass)
StateUpdateRouting
.
The resulting routing schema has the ignoring default route, i.e. if a custom route is not set, the entity state update is ignored.
I
- the type of the entity IDs to which the updates are routedidClass
- the class of identifiers served by this routingStateUpdateRouting
public boolean supports(java.lang.Class<? extends io.spine.base.EntityState> stateType)
@CanIgnoreReturnValue public <S extends io.spine.base.EntityState> StateUpdateRouting<I> route(java.lang.Class<S> stateClass, StateUpdateRoute<I,S> via) throws java.lang.IllegalStateException
If there is no specific route for the class of the passed entity state, the routing will use the default route.
S
- the type of the entity state messagestateClass
- the class of entity states to routevia
- the instance of the route to be usedthis
to allow chained calls when configuring the routingjava.lang.IllegalStateException
- if the route for this class is already setprotected Route<M,C,R> defaultRoute()
public void remove(java.lang.Class<? extends M> messageClass)
java.lang.IllegalStateException
- if a custom route for this message class was not previously setpublic R apply(M message, C context)
If there is no function for the passed message applies the default function.
apply
in interface Route<M extends com.google.protobuf.Message,C extends io.spine.base.MessageContext,R>
apply
in interface java.util.function.BiFunction<M extends com.google.protobuf.Message,C extends io.spine.base.MessageContext,R>
message
- the messagecontext
- the message context