| 1 | package org.sanmibuh.ddd.infrastructure; | |
| 2 | ||
| 3 | import java.util.List; | |
| 4 | import org.sanmibuh.ddd.port.Query; | |
| 5 | import org.sanmibuh.ddd.port.QueryBus; | |
| 6 | import org.sanmibuh.ddd.port.QueryHandler; | |
| 7 | ||
| 8 | public final class InMemoryQueryBus implements QueryBus { | |
| 9 | ||
| 10 | private final HandlerLookup<QueryHandler<?, ?>> lookup; | |
| 11 | ||
| 12 | public InMemoryQueryBus(final List<QueryHandler<?, ?>> handlers) { | |
| 13 | lookup = new HandlerLookup<>(handlers, QueryHandler.class); | |
| 14 | } | |
| 15 | ||
| 16 | @Override | |
| 17 | @SuppressWarnings("unchecked") | |
| 18 | public <R> R dispatch(final Query<R> query) { | |
| 19 | final QueryHandler<Query<R>, R> handler = | |
| 20 | (QueryHandler<Query<R>, R>) lookup.find(query.getClass()); | |
| 21 |
1
1. dispatch : replaced return value with null for org/sanmibuh/ddd/infrastructure/InMemoryQueryBus::dispatch → KILLED |
return handler.handle(query); |
| 22 | } | |
| 23 | } | |
Mutations | ||
| 21 |
1.1 |