From d08cbf6b8705df234077c49608de3c2f7ff0e3fa Mon Sep 17 00:00:00 2001 From: Kyle Gunger Date: Thu, 21 Nov 2019 18:35:14 -0500 Subject: [Update] Codebase updated to 0.2.8 ~ Rewrote files and documentation for cohesion ~ Removed I from the start of interface names --- .../java/net/transit/network/swap/Acceptor.java | 44 +++++++++++++++++++ .../java/net/transit/network/swap/IAcceptor.java | 31 -------------- .../java/net/transit/network/swap/IProvider.java | 37 ---------------- .../java/net/transit/network/swap/Provider.java | 50 ++++++++++++++++++++++ 4 files changed, 94 insertions(+), 68 deletions(-) create mode 100644 src/main/java/net/transit/network/swap/Acceptor.java delete mode 100644 src/main/java/net/transit/network/swap/IAcceptor.java delete mode 100644 src/main/java/net/transit/network/swap/IProvider.java create mode 100644 src/main/java/net/transit/network/swap/Provider.java (limited to 'src/main/java/net/transit/network/swap') diff --git a/src/main/java/net/transit/network/swap/Acceptor.java b/src/main/java/net/transit/network/swap/Acceptor.java new file mode 100644 index 0000000..9778095 --- /dev/null +++ b/src/main/java/net/transit/network/swap/Acceptor.java @@ -0,0 +1,44 @@ +package net.transit.network.swap; + +import net.transit.network.packet.Packet; +import net.transit.network.system.Node; + +/** + * @author Kyle Gunger + * + * @param The type of data accepted (in IPacket<> form) + */ +public interface Acceptor +{ + /** Returns the INode this Acceptor is attached to. All Acceptors and Provider must be attached to an INode to function. + * + * @return INode + */ + public Node getNode(); + + /** + * @return True if the Acceptor can accept packets. + */ + public boolean canAccept(); + + /** + * @param provided The packet provided. + * @return True if the Acceptor accepted the packet. + */ + public boolean accept(Packet provided); + + /** + * @return True if the Acceptor has a Provider assigned to it. + */ + public boolean hasProvider(); + + /**Set the provider of the Acceptor. The Acceptor can decide if it wants to adopt the Provider. + */ + public void setProvider(Provider provider); + + /** Request that the Acceptor close it's connection to a Provider. The Acceptor may also shut itself down if no more Providers are attached. + * + * @param provider The Provider + */ + public void shutdown(Provider provider); +} \ No newline at end of file diff --git a/src/main/java/net/transit/network/swap/IAcceptor.java b/src/main/java/net/transit/network/swap/IAcceptor.java deleted file mode 100644 index 6966b9a..0000000 --- a/src/main/java/net/transit/network/swap/IAcceptor.java +++ /dev/null @@ -1,31 +0,0 @@ -package net.transit.network.swap; - -import net.transit.network.packet.IPacket; - -/** - * @author Kyle Gunger - * - * @param The type of data accepted (in IPacket<> form) - */ -public interface IAcceptor -{ - /** - * @return True if the acceptor can accept packets. - */ - public boolean canAccept(); - - /** - * @param provided The packet provided. - * @return True if the acceptor accepted the packet. - */ - public boolean accept(IPacket provided); - - /** - * @return True if the acceptor has a provider assigned to it. - */ - public boolean hasProvider(); - - /**Set the provider of the acceptor. The acceptor can decide if it wants to adopt the provider. - */ - public void setProvider(IProvider provider); -} \ No newline at end of file diff --git a/src/main/java/net/transit/network/swap/IProvider.java b/src/main/java/net/transit/network/swap/IProvider.java deleted file mode 100644 index 03c9ca9..0000000 --- a/src/main/java/net/transit/network/swap/IProvider.java +++ /dev/null @@ -1,37 +0,0 @@ -package net.transit.network.swap; - -import net.transit.network.packet.IPacket; - -/** - * @author Kyle Gunger - * - * @param The type of data provided (in IPacket<> form) - */ -public interface IProvider -{ - /** - * @return True if the provider can provide a packet. - */ - public boolean canProvide(); - - /**Get the next packet from the provider - * - * @return IPacket<> - */ - public IPacket provide(); - - /**Retain the packet if the acceptor did not accept the packet. - * - * @param rejected The rejected packet - */ - public void retain(IPacket rejected); - - /** - * @return True if the acceptor has a provider assigned to it - */ - public boolean hasAcceptor(); - - /**Set the acceptor of the provider. The provider can decide if it wants to adopt the acceptor. - */ - public void setAcceptor(); -} \ No newline at end of file diff --git a/src/main/java/net/transit/network/swap/Provider.java b/src/main/java/net/transit/network/swap/Provider.java new file mode 100644 index 0000000..20656b8 --- /dev/null +++ b/src/main/java/net/transit/network/swap/Provider.java @@ -0,0 +1,50 @@ +package net.transit.network.swap; + +import net.transit.network.packet.Packet; +import net.transit.network.system.Node; + +/** + * @author Kyle Gunger + * + * @param The type of data provided (in IPacket<> form) + */ +public interface Provider +{ + /** Returns the INode this Provider is attached to. All Acceptors and Providers must be attached to an INode to function. + * + * @return INode + */ + public Node getNode(); + + /** + * @return True if the Provider can provide a packet. + */ + public boolean canProvide(); + + /**Get the next packet from the Provider + * + * @return IPacket<> + */ + public Packet provide(); + + /**Retain the packet if the Acceptor did not accept the packet. + * + * @param rejected The rejected packet + */ + public void retain(Packet rejected); + + /** + * @return True if the Provider has an Acceptor assigned to it + */ + public boolean hasAcceptor(); + + /**Set the Acceptor of the Provider. The Provider can decide if it wants to adopt the Acceptor. + */ + public void setAcceptor(Acceptor acceptor); + + /** Request that the Provider close it's connection to a Acceptor. The Provider may also shut itself down if no more Acceptors are attached. + * + * @param acceptor The Acceptor + */ + public void shutdown(Acceptor acceptor); +} \ No newline at end of file -- cgit v1.2.3