public interface IWiredNetwork
IWiredNode
s, a set of connections between them, and a series
of peripherals.
Networks from a connected graph. This means there is some path between all nodes on the network. Further more, if
there is some path between two nodes then they must be on the same network. IWiredNetwork
will automatically
handle the merging and splitting of networks (and thus changing of available nodes and peripherals) as connections
change.
This does mean one can not rely on the network remaining consistent between subsequent operations. Consequently,
it is generally preferred to use the methods provided by IWiredNode
.IWiredNode.getNetwork()
Modifier and Type | Method and Description |
---|---|
boolean |
connect(IWiredNode left,
IWiredNode right)
Create a connection between two nodes.
|
boolean |
disconnect(IWiredNode left,
IWiredNode right)
Destroy a connection between this node and another.
|
boolean |
remove(IWiredNode node)
Sever all connections this node has, removing it from this network.
|
void |
updatePeripherals(IWiredNode node,
java.util.Map<java.lang.String,IPeripheral> peripherals)
Update the peripherals a node provides.
|
boolean connect(@Nonnull IWiredNode left, @Nonnull IWiredNode right)
left
- The first node to connectright
- The second node to connecttrue
if a connection was created or false
if the connection already exists.java.lang.IllegalStateException
- If neither node is on the network.java.lang.IllegalArgumentException
- If left
and right
are equal.IWiredNode.connectTo(IWiredNode)
,
connect(IWiredNode, IWiredNode)
boolean disconnect(@Nonnull IWiredNode left, @Nonnull IWiredNode right)
left
- The first node in the connection.right
- The second node in the connection.true
if a connection was destroyed or false
if no connection exists.java.lang.IllegalArgumentException
- If either node is not on the network.java.lang.IllegalArgumentException
- If left
and right
are equal.IWiredNode.disconnectFrom(IWiredNode)
,
connect(IWiredNode, IWiredNode)
boolean remove(@Nonnull IWiredNode node)
node
- The node to removejava.lang.IllegalArgumentException
- If the node is not in the network.IWiredNode.remove()
void updatePeripherals(@Nonnull IWiredNode node, @Nonnull java.util.Map<java.lang.String,IPeripheral> peripherals)
node
- The node to attach peripherals for.peripherals
- The new peripherals for this node.java.lang.IllegalArgumentException
- If the node is not in the network.IWiredNode.updatePeripherals(Map)