transition enricher rabbit
This commit is contained in:
@@ -14,6 +14,9 @@ public interface StateMachineService {
|
||||
// Quirky pattern 2: Generic Varargs
|
||||
<T extends IEvent> void sendEventsVarargs(T... events);
|
||||
|
||||
// Child class of Spring's GenericMessage with a generic payload
|
||||
<T extends click.kamil.domain.OrderEvent, P> void sendCustomMessage(click.kamil.domain.CustomStateMachineMessage<T, P> customMessage);
|
||||
|
||||
// Quirky pattern 3: Multiple generic bounds (Intersection Types)
|
||||
<T extends IEvent & java.io.Serializable & Cloneable> T processQuirkyEvent(T event);
|
||||
}
|
||||
|
||||
@@ -54,12 +54,21 @@ public class StateMachineServiceImpl implements StateMachineService {
|
||||
@Override
|
||||
@SafeVarargs
|
||||
public final <T extends IEvent> void sendEventsVarargs(T... events) {
|
||||
// Quirky pattern 2: Iterating over generic varargs
|
||||
for (T event : events) {
|
||||
sendMessage(event);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends OrderEvent, P> void sendCustomMessage(click.kamil.domain.CustomStateMachineMessage<T, P> customMessage) {
|
||||
// Because CustomStateMachineMessage extends GenericMessage<T> and implements Message<T>,
|
||||
// we can pass it directly to the state machine as long as T resolves to OrderEvent!
|
||||
|
||||
// We cast it to Message<OrderEvent> to satisfy Mono's strict type requirements
|
||||
org.springframework.messaging.Message<OrderEvent> msg = (org.springframework.messaging.Message<OrderEvent>) customMessage;
|
||||
stateMachine.sendEvent(Mono.just(msg)).subscribe();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends IEvent & java.io.Serializable & Cloneable> T processQuirkyEvent(T event) {
|
||||
// Quirky pattern 3: Multiple bounds, returning the same generic type
|
||||
|
||||
Reference in New Issue
Block a user