- java.lang.Object
-
- com.seiama.event.registry.SimpleEventRegistry<E>
-
- Type Parameters:
E- the base event type
- All Implemented Interfaces:
EventRegistry<E>
public class SimpleEventRegistry<E> extends Object implements EventRegistry<E>
A simple implementation of an event registry.- Since:
- 1.0.0
-
-
Constructor Summary
Constructors Constructor Description SimpleEventRegistry(@NotNull Class<E> type)Constructs a newSimpleEventRegistry.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends E>
@NotNull EventSubscription<T>subscribe(@NotNull Class<T> event, @NotNull EventConfig config, @NotNull EventSubscriber<? super T> subscriber)Registers the givensubscriberto receive events.@NotNull List<EventSubscription<? super E>>subscriptions(@NotNull Class<? extends E> event)Gets an unmodifiable list containing all subscriptions currently registered for events of typeevent.@NotNull Class<E>type()Gets the base event type.voidunsubscribeIf(@NotNull Predicate<EventSubscription<? super E>> predicate)Removes subscriptions matchingpredicate.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.seiama.event.registry.EventRegistry
subscribe, subscribed
-
-
-
-
Method Detail
-
type
@NotNull public @NotNull Class<E> type()
Description copied from interface:EventRegistryGets the base event type.This is represented by the
Etype parameter.- Specified by:
typein interfaceEventRegistry<E>- Returns:
- the base event type
-
subscribe
@NotNull public <T extends E> @NotNull EventSubscription<T> subscribe(@NotNull @NotNull Class<T> event, @NotNull @NotNull EventConfig config, @NotNull @NotNull EventSubscriber<? super T> subscriber)
Description copied from interface:EventRegistryRegisters the givensubscriberto receive events.- Specified by:
subscribein interfaceEventRegistry<E>- Type Parameters:
T- the event type- Parameters:
event- the event typeconfig- the event configurationsubscriber- the subscriber
-
unsubscribeIf
public void unsubscribeIf(@NotNull @NotNull Predicate<EventSubscription<? super E>> predicate)Description copied from interface:EventRegistryRemoves subscriptions matchingpredicate.- Specified by:
unsubscribeIfin interfaceEventRegistry<E>- Parameters:
predicate- the predicate used to determine which subscriptions to remove
-
subscriptions
@NotNull public @NotNull List<EventSubscription<? super E>> subscriptions(@NotNull @NotNull Class<? extends E> event)
Description copied from interface:EventRegistryGets an unmodifiable list containing all subscriptions currently registered for events of typeevent.- Specified by:
subscriptionsin interfaceEventRegistry<E>- Returns:
- a list of all subscriptions for events of type
event
-
-