diff --git a/src/mightypork/utils/eventbus/BusAccess.java b/src/mightypork/utils/eventbus/BusAccess.java deleted file mode 100644 index 8085fa7..0000000 --- a/src/mightypork/utils/eventbus/BusAccess.java +++ /dev/null @@ -1,16 +0,0 @@ -package mightypork.utils.eventbus; - - -/** - * Access to an {@link EventBus} instance - * - * @author Ondřej Hruška (MightyPork) - */ -public interface BusAccess { - - /** - * @return event bus - */ - EventBus getEventBus(); - -} diff --git a/src/mightypork/utils/eventbus/EventBus.java b/src/mightypork/utils/eventbus/EventBus.java index 9ef7b8c..2970e69 100644 --- a/src/mightypork/utils/eventbus/EventBus.java +++ b/src/mightypork/utils/eventbus/EventBus.java @@ -25,7 +25,7 @@ import mightypork.utils.logging.Log; * * @author Ondřej Hruška (MightyPork) */ -final public class EventBus implements Destroyable, BusAccess { +final public class EventBus implements Destroyable { /** * Queued event holder @@ -375,11 +375,4 @@ final public class EventBus implements Destroyable, BusAccess { return true; } - - @Override - public EventBus getEventBus() - { - return this; // just for compatibility use-case - } - } diff --git a/src/mightypork/utils/eventbus/clients/BusNode.java b/src/mightypork/utils/eventbus/clients/BusNode.java index 44b7bdf..6ebf8ce 100644 --- a/src/mightypork/utils/eventbus/clients/BusNode.java +++ b/src/mightypork/utils/eventbus/clients/BusNode.java @@ -5,8 +5,6 @@ import java.util.Collection; import java.util.LinkedHashSet; import java.util.Set; -import mightypork.utils.annotations.Stub; -import mightypork.utils.eventbus.BusAccess; import mightypork.utils.eventbus.EventBus; @@ -16,58 +14,13 @@ import mightypork.utils.eventbus.EventBus; * * @author Ondřej Hruška (MightyPork) */ -public abstract class BusNode implements BusAccess, ClientHub { - - private BusAccess busAccess; +public abstract class BusNode implements ClientHub { private final Set clients = new LinkedHashSet<>(); private boolean listening = true; private boolean delegating = true; - /** - * @param busAccess access to bus - */ - public BusNode(BusAccess busAccess) { - setBusAccess(busAccess); - } - - - /** - * Create without a bus access. Bus access should be set using the - * setBusAccess() method. - */ - public BusNode() { - } - - - /** - * Handler called when bus access first provides a valid bus instance.
- * The node may now eg. subscribe to the bus. - */ - @Stub - public void onBusReady() - { - // do stuff - } - - - /** - * Assign a bus access. If the buss access provides a buss, the onBusReady() - * method will be called. - * - * @param busAccess the assigned bus access - */ - public final void setBusAccess(BusAccess busAccess) - { - this.busAccess = busAccess; - - if (getEventBus() != null) { - onBusReady(); - } - } - - @Override public Collection getChildClients() { @@ -97,10 +50,6 @@ public abstract class BusNode implements BusAccess, ClientHub { @Override public void addChildClient(Object client) { - if (client instanceof RootBusNode) { - throw new IllegalArgumentException("Cannot nest RootBusNode."); - } - clients.add(client); } @@ -139,13 +88,4 @@ public abstract class BusNode implements BusAccess, ClientHub { { this.delegating = delegating; } - - - @Override - public EventBus getEventBus() - { - if(busAccess==null) return null; - return busAccess.getEventBus(); - } - } diff --git a/src/mightypork/utils/eventbus/clients/RootBusNode.java b/src/mightypork/utils/eventbus/clients/RootBusNode.java deleted file mode 100644 index bc11f6c..0000000 --- a/src/mightypork/utils/eventbus/clients/RootBusNode.java +++ /dev/null @@ -1,60 +0,0 @@ -package mightypork.utils.eventbus.clients; - - -import mightypork.utils.annotations.Stub; -import mightypork.utils.eventbus.BusAccess; -import mightypork.utils.interfaces.Destroyable; - - -/** - * Bus node that should be directly attached to the bus. - * - * @author Ondřej Hruška (MightyPork) - */ -public abstract class RootBusNode extends BusNode implements Destroyable { - - /** - * Create with a bus access. - * - * @param busAccess access to bus - */ - public RootBusNode(BusAccess busAccess) { - super(busAccess); - } - - - /** - * Create without a bus access. It should be assigned later. - */ - public RootBusNode() { - } - - - @Override - public void onBusReady() - { - getEventBus().subscribe(this); - } - - - @Override - public final void destroy() - { - deinit(); - - if (getEventBus() != null) { - getEventBus().unsubscribe(this); - } - } - - - /** - * Deinitialize the node (subsystem)
- * (called during destruction) - */ - @Stub - protected void deinit() - { - } - -}