asset workspace progress
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
package p.studio.utilities.events;
|
||||
|
||||
public interface EventBusPublisher<T extends SimpleEvent> {
|
||||
<E extends T> void publish(E event);
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public final class TypedEventBus {
|
||||
public final class TypedEventBus implements EventBusPublisher<SimpleEvent> {
|
||||
private final AtomicLong nextSubscriptionId = new AtomicLong(1L);
|
||||
private final ConcurrentMap<Class<?>, ConcurrentMap<Long, Consumer<Object>>> subscriptionsByType =
|
||||
new ConcurrentHashMap<>();
|
||||
@@ -40,7 +40,8 @@ public final class TypedEventBus {
|
||||
};
|
||||
}
|
||||
|
||||
public void publish(Object event) {
|
||||
@Override
|
||||
public <E extends SimpleEvent> void publish(E event) {
|
||||
Objects.requireNonNull(event, "event");
|
||||
|
||||
final ConcurrentMap<Long, Consumer<Object>> subscriptions = subscriptionsByType.get(event.getClass());
|
||||
|
||||
Reference in New Issue
Block a user