mirror of
https://github.com/zaaarf/geb.git
synced 2024-11-22 14:24:49 +01:00
chore: identifier leftovers
This commit is contained in:
parent
0c16dc9ff4
commit
fd87c90d63
2 changed files with 5 additions and 14 deletions
|
@ -14,12 +14,6 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||||
* @since 0.1.0
|
* @since 0.1.0
|
||||||
*/
|
*/
|
||||||
public class GEB implements IBus {
|
public class GEB implements IBus {
|
||||||
|
|
||||||
/**
|
|
||||||
* The identifier of this bus. Methods
|
|
||||||
*/
|
|
||||||
private final String identifier;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link Map} tying each listener class to its instance.
|
* A {@link Map} tying each listener class to its instance.
|
||||||
*/
|
*/
|
||||||
|
@ -31,11 +25,9 @@ public class GEB implements IBus {
|
||||||
private final Map<Class<? extends IEvent>, IEventDispatcher> dispatchMap;
|
private final Map<Class<? extends IEvent>, IEventDispatcher> dispatchMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The public constructor.
|
* The default public constructor.
|
||||||
* @param identifier a {@link String} uniquely identifying this bus
|
|
||||||
*/
|
*/
|
||||||
public GEB(String identifier) {
|
public GEB() {
|
||||||
this.identifier = identifier;
|
|
||||||
this.listenerMap = new ConcurrentHashMap<>();
|
this.listenerMap = new ConcurrentHashMap<>();
|
||||||
this.dispatchMap = new ConcurrentHashMap<>();
|
this.dispatchMap = new ConcurrentHashMap<>();
|
||||||
for(IEventDispatcher dispatcher : ServiceLoader.load(IEventDispatcher.class))
|
for(IEventDispatcher dispatcher : ServiceLoader.load(IEventDispatcher.class))
|
||||||
|
@ -58,6 +50,6 @@ public class GEB implements IBus {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean handleEvent(IEvent event) {
|
public boolean handleEvent(IEvent event) {
|
||||||
return this.dispatchMap.get(event.getClass()).callListeners(this.identifier, event, this.listenerMap);
|
return this.dispatchMap.get(event.getClass()).callListeners(event, this.listenerMap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,13 +10,12 @@ import java.util.Map;
|
||||||
*/
|
*/
|
||||||
public interface IEventDispatcher {
|
public interface IEventDispatcher {
|
||||||
/**
|
/**
|
||||||
* Calls all listeners for the given identifier.
|
* Calls all listeners for the given event.
|
||||||
* @param identifier the identifier of the bus that's calling this
|
|
||||||
* @param event the event to call
|
* @param event the event to call
|
||||||
* @param listeners a map mapping each {@link IListener} class to its instance
|
* @param listeners a map mapping each {@link IListener} class to its instance
|
||||||
* @return the value {@link IBus#handleEvent(IEvent)} will return for this
|
* @return the value {@link IBus#handleEvent(IEvent)} will return for this
|
||||||
*/
|
*/
|
||||||
boolean callListeners(String identifier, IEvent event, Map<Class<? extends IListener>, IListener> listeners);
|
boolean callListeners(IEvent event, Map<Class<? extends IListener>, IListener> listeners);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the {@link Class} representing the event this dispatcher works with
|
* @return the {@link Class} representing the event this dispatcher works with
|
||||||
|
|
Loading…
Reference in a new issue