diff options
Diffstat (limited to 'src/main/java/ChannelNode.java')
| -rw-r--r-- | src/main/java/ChannelNode.java | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/src/main/java/ChannelNode.java b/src/main/java/ChannelNode.java index 20a7ac0..6c2e9a3 100644 --- a/src/main/java/ChannelNode.java +++ b/src/main/java/ChannelNode.java | |||
| @@ -43,8 +43,8 @@ public class ChannelNode implements IChannelNode { | |||
| 43 | if(dir == null) throw new IllegalArgumentException("dir is null"); | 43 | if(dir == null) throw new IllegalArgumentException("dir is null"); |
| 44 | 44 | ||
| 45 | Direction.overVals(Map.ofEntries( | 45 | Direction.overVals(Map.ofEntries( |
| 46 | entry(Direction.INCOMING, () -> incoming.put(node, incoming.get(node) + 1)), | 46 | entry(Direction.INCOMING, () -> incoming.put(node, ((incoming.get(node) != null) ? incoming.get(node) : 0) + 1)), |
| 47 | entry(Direction.OUTGOING, () -> outgoing.put(node, outgoing.get(node) + 1)) | 47 | entry(Direction.OUTGOING, () -> outgoing.put(node, ((outgoing.get(node) != null) ? outgoing.get(node) : 0) + 1)) |
| 48 | ), dir); | 48 | ), dir); |
| 49 | } | 49 | } |
| 50 | 50 | ||
| @@ -56,8 +56,8 @@ public class ChannelNode implements IChannelNode { | |||
| 56 | 56 | ||
| 57 | for(IChannelNode node: nodes) { | 57 | for(IChannelNode node: nodes) { |
| 58 | Direction.overVals(Map.ofEntries( | 58 | Direction.overVals(Map.ofEntries( |
| 59 | entry(Direction.INCOMING, () -> incoming.put(node, incoming.get(node) + 1)), | 59 | entry(Direction.INCOMING, () -> incoming.put(node,((incoming.get(node) != null) ? incoming.get(node) : 0) + 1)), |
| 60 | entry(Direction.OUTGOING, () -> outgoing.put(node, outgoing.get(node) + 1)) | 60 | entry(Direction.OUTGOING, () -> outgoing.put(node,((outgoing.get(node) != null) ? outgoing.get(node) : 0) + 1)) |
| 61 | ), dir); | 61 | ), dir); |
| 62 | } | 62 | } |
| 63 | } | 63 | } |
| @@ -89,13 +89,10 @@ public class ChannelNode implements IChannelNode { | |||
| 89 | } | 89 | } |
| 90 | 90 | ||
| 91 | @Override | 91 | @Override |
| 92 | public void clearConnections(Direction dir) throws IllegalArgumentException { | 92 | public void clearConnections() throws IllegalArgumentException { |
| 93 | if(dir == null) throw new IllegalArgumentException("dir is null"); | 93 | // I have no idea why this is throwing an unsupported operation exception |
| 94 | 94 | incoming.clear(); | |
| 95 | Direction.overVals(Map.ofEntries( | 95 | outgoing.clear(); |
| 96 | entry(Direction.INCOMING, () -> incoming.clear()), | ||
| 97 | entry(Direction.OUTGOING, () -> outgoing.clear()) | ||
| 98 | ), dir); | ||
| 99 | } | 96 | } |
| 100 | 97 | ||
| 101 | @Override | 98 | @Override |
