Class PreemptiveSubscriber<T>

  • Type Parameters:
    T - the type of messages of the Subscriber can accept
    All Implemented Interfaces:
    Subscriber<T>

    public final class PreemptiveSubscriber<T>
    extends Object
    implements Subscriber<T>
    A Subscriber that calls the given predicate for each message. The return value of the predicate decides, if the delivery should be continued (true), or preempted (false).
    See Also:
    EventMaid Documentation
    • Constructor Detail

      • PreemptiveSubscriber

        public PreemptiveSubscriber()
    • Method Detail

      • preemptiveSubscriber

        public static <T> PreemptiveSubscriber<T> preemptiveSubscriber​(Predicate<T> predicate)
        Factory method for a new PreemptiveSubscriber.
        Type Parameters:
        T - the type of messages the Subscriber accepts
        Parameters:
        predicate - the predicate to apply on each message
        Returns:
        a new PreemptiveSubscriber
      • accept

        public AcceptingBehavior accept​(T message)
        Description copied from interface: Subscriber
        Delivers the message to the Subscriber. The Subscriber can decide, if the delivery continues or is preempted by returning the respective AcceptingBehavior.
        Specified by:
        accept in interface Subscriber<T>
        Parameters:
        message - the message
        Returns:
        AcceptingBehavior to continue or preempt delivery
      • getSubscriptionId

        public SubscriptionId getSubscriptionId()
        Description copied from interface: Subscriber
        The unique and constant SubscriptionId of the Subscriber.
        Specified by:
        getSubscriptionId in interface Subscriber<T>
        Returns:
        the Subscriber's SubscriptionId