T - the event typepublic interface SingleSubscriptionBuilder<T extends Event> extends SubscriptionBuilder<T>
SingleSubscriptions.DEFAULT_EXCEPTION_CONSUMER| Modifier and Type | Method and Description |
|---|---|
default SingleSubscription<T> |
biHandler(BiConsumer<SingleSubscription<T>,? super T> handler)
Builds and registers the Handler.
|
SingleSubscriptionBuilder<T> |
exceptionConsumer(BiConsumer<? super T,Throwable> consumer)
Sets the exception consumer for the handler.
|
default SingleSubscriptionBuilder<T> |
expireAfter(long maxCalls)
Sets the number of calls until the handler will automatically be unregistered
|
default SingleSubscriptionBuilder<T> |
expireAfter(long duration,
TimeUnit unit)
Sets the expiry time on the handler
|
SingleSubscriptionBuilder<T> |
expireIf(BiPredicate<SingleSubscription<T>,T> predicate,
ExpiryTestStage... testPoints)
Add a expiry predicate.
|
default SingleSubscriptionBuilder<T> |
expireIf(Predicate<T> predicate)
Add a expiry predicate.
|
SingleSubscriptionBuilder<T> |
filter(Predicate<T> predicate)
Adds a filter to the handler.
|
default SingleSubscription<T> |
handler(Consumer<? super T> handler)
Builds and registers the Handler.
|
SingleHandlerList<T> |
handlers()
Return the handler list builder to append handlers for the event.
|
SingleSubscriptionBuilder<T> |
handleSubclasses()
Sets that the handler should accept subclasses of the event type.
|
static <T extends Event> |
newBuilder(Class<T> eventClass)
Makes a HandlerBuilder for a given event
|
static <T extends Event> |
newBuilder(Class<T> eventClass,
EventPriority priority)
Makes a HandlerBuilder for a given event
|
@Nonnull static <T extends Event> SingleSubscriptionBuilder<T> newBuilder(@Nonnull Class<T> eventClass)
T - the event typeeventClass - the class of the eventSingleSubscriptionBuilder to construct the event handlerNullPointerException - if eventClass is null@Nonnull static <T extends Event> SingleSubscriptionBuilder<T> newBuilder(@Nonnull Class<T> eventClass, @Nonnull EventPriority priority)
T - the event typeeventClass - the class of the eventpriority - the priority to listen atSingleSubscriptionBuilder to construct the event handlerNullPointerException - if eventClass or priority is null@Nonnull default SingleSubscriptionBuilder<T> expireIf(@Nonnull Predicate<T> predicate)
SubscriptionBuilderexpireIf in interface SubscriptionBuilder<T extends Event>predicate - the expiry test@Nonnull default SingleSubscriptionBuilder<T> expireAfter(long duration, @Nonnull TimeUnit unit)
SubscriptionBuilderexpireAfter in interface SubscriptionBuilder<T extends Event>duration - the duration until expiryunit - the unit for the duration@Nonnull default SingleSubscriptionBuilder<T> expireAfter(long maxCalls)
SubscriptionBuilderThe call counter is only incremented if the event call passes all filters and if the handler completes without throwing an exception.
expireAfter in interface SubscriptionBuilder<T extends Event>maxCalls - the number of times the handler will be called until being unregistered.@Nonnull SingleSubscriptionBuilder<T> filter(@Nonnull Predicate<T> predicate)
SubscriptionBuilderAn event will only be handled if it passes all filters. Filters are evaluated in the order they are registered.
filter in interface SubscriptionBuilder<T extends Event>predicate - the filter@Nonnull SingleSubscriptionBuilder<T> expireIf(@Nonnull BiPredicate<SingleSubscription<T>,T> predicate, @Nonnull ExpiryTestStage... testPoints)
predicate - the expiry testtestPoints - when to test the expiry predicate@Nonnull SingleSubscriptionBuilder<T> exceptionConsumer(@Nonnull BiConsumer<? super T,Throwable> consumer)
If an exception is thrown in the handler, it is passed to this consumer to be swallowed.
consumer - the consumerNullPointerException - if the consumer is null@Nonnull SingleSubscriptionBuilder<T> handleSubclasses()
@Nonnull SingleHandlerList<T> handlers()
@Nonnull default SingleSubscription<T> handler(@Nonnull Consumer<? super T> handler)
handler - the consumer responsible for handling the event.SingleSubscription instance.NullPointerException - if the handler is null@Nonnull default SingleSubscription<T> biHandler(@Nonnull BiConsumer<SingleSubscription<T>,? super T> handler)
handler - the bi-consumer responsible for handling the event.SingleSubscription instance.NullPointerException - if the handler is nullCopyright © 2020. All rights reserved.