Class PreemptiveSubscriber<T>
- java.lang.Object
-
- de.quantummaid.eventmaid.subscribing.PreemptiveSubscriber<T>
-
- Type Parameters:
T- the type of messages of theSubscribercan accept
- All Implemented Interfaces:
Subscriber<T>
public final class PreemptiveSubscriber<T> extends Object implements Subscriber<T>
ASubscriberthat calls the givenpredicatefor each message. The return value of thepredicatedecides, if the delivery should be continued (true), or preempted (false).- See Also:
- EventMaid Documentation
-
-
Constructor Summary
Constructors Constructor Description PreemptiveSubscriber()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description AcceptingBehavioraccept(T message)Delivers the message to theSubscriber.SubscriptionIdgetSubscriptionId()The unique and constantSubscriptionIdof theSubscriber.static <T> PreemptiveSubscriber<T>preemptiveSubscriber(Predicate<T> predicate)Factory method for a newPreemptiveSubscriber.
-
-
-
Method Detail
-
preemptiveSubscriber
public static <T> PreemptiveSubscriber<T> preemptiveSubscriber(Predicate<T> predicate)
Factory method for a newPreemptiveSubscriber.- Type Parameters:
T- the type of messages theSubscriberaccepts- Parameters:
predicate- thepredicateto apply on each message- Returns:
- a new
PreemptiveSubscriber
-
accept
public AcceptingBehavior accept(T message)
Description copied from interface:SubscriberDelivers the message to theSubscriber. TheSubscribercan decide, if the delivery continues or is preempted by returning the respectiveAcceptingBehavior.- Specified by:
acceptin interfaceSubscriber<T>- Parameters:
message- the message- Returns:
AcceptingBehaviorto continue or preempt delivery
-
getSubscriptionId
public SubscriptionId getSubscriptionId()
Description copied from interface:SubscriberThe unique and constantSubscriptionIdof theSubscriber.- Specified by:
getSubscriptionIdin interfaceSubscriber<T>- Returns:
- the
Subscriber'sSubscriptionId
-
-