| 1 | package com.hammurapi.eventbus; |
| 2 | |
| 3 | /** |
| 4 | * This class delegates to another event handler. The class is initialized from the master handler. Initialization parameters |
| 5 | * can be changed afterwards. |
| 6 | * @author Pavel Vlasov |
| 7 | * |
| 8 | * @param <E> |
| 9 | * @param <P> |
| 10 | * @param <C> |
| 11 | * @param <H> |
| 12 | * @param <S> |
| 13 | */ |
| 14 | public class EventHandlerFilter<E, P extends Comparable<P>, C, H extends EventBus.Handle<E,P,C>, S extends EventStore<E,P,C,H,S>> extends AbstractEventHandler<E, P, C, H, S> { |
| 15 | |
| 16 | private EventHandler<E, P, C, H, S> master; |
| 17 | |
| 18 | public EventHandlerFilter(EventHandler<E,P,C,H,S> master) { |
| 19 | super( |
| 20 | master.getCardinality(), |
| 21 | master.getPriority(), |
| 22 | master.getContext(), |
| 23 | master.consumes(), |
| 24 | master.isOneOff(), |
| 25 | master.getMode(), |
| 26 | master.getPredicate()); |
| 27 | |
| 28 | this.master = master; |
| 29 | } |
| 30 | |
| 31 | @Override |
| 32 | public void post(EventDispatchContext<E, P, C, H, S> context, E... events) { |
| 33 | master.post(context, events); |
| 34 | } |
| 35 | |
| 36 | public EventHandler<E, P, C, H, S> getMaster() { |
| 37 | return master; |
| 38 | } |
| 39 | |
| 40 | } |