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); }