Interface WiredNetwork
WiredNode
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. WiredNetwork
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 WiredNode
.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Create a connection between two nodes.boolean
disconnect
(WiredNode left, WiredNode right) Destroy a connection between this node and another.boolean
Sever all connections this node has, removing it from this network.void
updatePeripherals
(WiredNode node, Map<String, IPeripheral> peripherals) Update the peripherals a node provides.
-
Method Details
-
connect
Create a connection between two nodes.This should only be used on the server thread.
- Parameters:
left
- The first node to connectright
- The second node to connect- Returns:
true
if a connection was created orfalse
if the connection already exists.- Throws:
IllegalStateException
- If neither node is on the network.IllegalArgumentException
- Ifleft
andright
are equal.- See Also:
-
disconnect
Destroy a connection between this node and another.This should only be used on the server thread.
- Parameters:
left
- The first node in the connection.right
- The second node in the connection.- Returns:
true
if a connection was destroyed orfalse
if no connection exists.- Throws:
IllegalArgumentException
- If either node is not on the network.IllegalArgumentException
- Ifleft
andright
are equal.- See Also:
-
remove
Sever all connections this node has, removing it from this network.This should only be used on the server thread. You should only call this on nodes that your network element owns.
- Parameters:
node
- The node to remove- Returns:
- Whether this node was removed from the network. One cannot remove a node from a network where it is the only element.
- Throws:
IllegalArgumentException
- If the node is not in the network.- See Also:
-
updatePeripherals
Update the peripherals a node provides.This should only be used on the server thread. You should only call this on nodes that your network element owns.
- Parameters:
node
- The node to attach peripherals for.peripherals
- The new peripherals for this node.- Throws:
IllegalArgumentException
- If the node is not in the network.- See Also:
-