T - the handled typepublic interface MergedSubscriptionBuilder<T> extends SubscriptionBuilder<T>
MergedSubscriptions.DEFAULT_EXCEPTION_CONSUMER| Modifier and Type | Method and Description |
|---|---|
default MergedSubscription<T> |
biHandler(BiConsumer<MergedSubscription<T>,? super T> handler)
Builds and registers the Handler.
|
<E extends Event> |
bindEvent(Class<E> eventClass,
EventPriority priority,
Function<E,T> function)
Binds this handler to an event
|
<E extends Event> |
bindEvent(Class<E> eventClass,
Function<E,T> function)
Binds this handler to an event
|
MergedSubscriptionBuilder<T> |
exceptionConsumer(BiConsumer<Event,Throwable> consumer)
Sets the exception consumer for the handler.
|
default MergedSubscriptionBuilder<T> |
expireAfter(long maxCalls)
Sets the number of calls until the handler will automatically be unregistered
|
default MergedSubscriptionBuilder<T> |
expireAfter(long duration,
TimeUnit unit)
Sets the expiry time on the handler
|
MergedSubscriptionBuilder<T> |
expireIf(BiPredicate<MergedSubscription<T>,T> predicate,
ExpiryTestStage... testPoints)
Add a expiry predicate.
|
default MergedSubscriptionBuilder<T> |
expireIf(Predicate<T> predicate)
Add a expiry predicate.
|
MergedSubscriptionBuilder<T> |
filter(Predicate<T> predicate)
Adds a filter to the handler.
|
default MergedSubscription<T> |
handler(Consumer<? super T> handler)
Builds and registers the Handler.
|
MergedHandlerList<T> |
handlers()
Return the handler list builder to append handlers for the event.
|
static <S extends Event> |
newBuilder(Class<S> superClass,
Class<? extends S>... eventClasses)
Makes a MergedHandlerBuilder for a super event class
|
static <S extends Event> |
newBuilder(Class<S> superClass,
EventPriority priority,
Class<? extends S>... eventClasses)
Makes a MergedHandlerBuilder for a super event class
|
static <T> MergedSubscriptionBuilder<T> |
newBuilder(Class<T> handledClass)
Makes a MergedHandlerBuilder for a given super type
|
static <T> MergedSubscriptionBuilder<T> |
newBuilder(TypeToken<T> type)
Makes a MergedHandlerBuilder for a given super type
|
@Nonnull static <T> MergedSubscriptionBuilder<T> newBuilder(@Nonnull Class<T> handledClass)
T - the super type classhandledClass - the super type of the event handlerMergedSubscriptionBuilder to construct the event handler@Nonnull static <T> MergedSubscriptionBuilder<T> newBuilder(@Nonnull TypeToken<T> type)
T - the super type classtype - the super type of the event handlerMergedSubscriptionBuilder to construct the event handler@Nonnull @SafeVarargs static <S extends Event> MergedSubscriptionBuilder<S> newBuilder(@Nonnull Class<S> superClass, @Nonnull Class<? extends S>... eventClasses)
S - the super class typesuperClass - the abstract super event classeventClasses - the event classes to be bound toMergedSubscriptionBuilder to construct the event handler@Nonnull @SafeVarargs static <S extends Event> MergedSubscriptionBuilder<S> newBuilder(@Nonnull Class<S> superClass, @Nonnull EventPriority priority, @Nonnull Class<? extends S>... eventClasses)
S - the super class typesuperClass - the abstract super event classpriority - the priority to listen ateventClasses - the event classes to be bound toMergedSubscriptionBuilder to construct the event handler@Nonnull default MergedSubscriptionBuilder<T> expireIf(@Nonnull Predicate<T> predicate)
SubscriptionBuilderexpireIf in interface SubscriptionBuilder<T>predicate - the expiry test@Nonnull default MergedSubscriptionBuilder<T> expireAfter(long duration, @Nonnull TimeUnit unit)
SubscriptionBuilderexpireAfter in interface SubscriptionBuilder<T>duration - the duration until expiryunit - the unit for the duration@Nonnull default MergedSubscriptionBuilder<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>maxCalls - the number of times the handler will be called until being unregistered.@Nonnull MergedSubscriptionBuilder<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>predicate - the filter@Nonnull MergedSubscriptionBuilder<T> expireIf(@Nonnull BiPredicate<MergedSubscription<T>,T> predicate, @Nonnull ExpiryTestStage... testPoints)
predicate - the expiry testtestPoints - when to test the expiry predicate@Nonnull <E extends Event> MergedSubscriptionBuilder<T> bindEvent(@Nonnull Class<E> eventClass, @Nonnull Function<E,T> function)
E - the event classeventClass - the event class to bind tofunction - the function to remap the event@Nonnull <E extends Event> MergedSubscriptionBuilder<T> bindEvent(@Nonnull Class<E> eventClass, @Nonnull EventPriority priority, @Nonnull Function<E,T> function)
E - the event classeventClass - the event class to bind topriority - the priority to listen atfunction - the function to remap the event@Nonnull MergedSubscriptionBuilder<T> exceptionConsumer(@Nonnull BiConsumer<Event,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 MergedHandlerList<T> handlers()
@Nonnull default MergedSubscription<T> handler(@Nonnull Consumer<? super T> handler)
handler - the consumer responsible for handling the event.MergedSubscription instance.NullPointerException - if the handler is nullIllegalStateException - if no events have been bound to@Nonnull default MergedSubscription<T> biHandler(@Nonnull BiConsumer<MergedSubscription<T>,? super T> handler)
handler - the bi-consumer responsible for handling the event.MergedSubscription instance.NullPointerException - if the handler is nullIllegalStateException - if no events have been bound toCopyright © 2020. All rights reserved.