Slide 70
Slide 70 text
R E A L E V E N T A P P L I E R
public class HubEventApplier implements EventApplier {
static Hub applyHubMovedEvent(Hub h, HubMovedEvent event) {
Hub hub = new Hub(h);
hub.locationId = UUID.fromString(event.newLocationId);
return hub;
}
public static Hub apply(Hub hub, Event event) {
return appliers
.get(event.getClass())
.apply(hub, event);
}
static Map appliers = HashMap.of(
HubMovedEvent.class,
(hub, event) -> applyHubMovedEvent(hub, event)
);
}