summaryrefslogtreecommitdiff
path: root/src/main/java/IChannelNode.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/IChannelNode.java')
-rw-r--r--src/main/java/IChannelNode.java23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/main/java/IChannelNode.java b/src/main/java/IChannelNode.java
index baf7572..a6446f1 100644
--- a/src/main/java/IChannelNode.java
+++ b/src/main/java/IChannelNode.java
@@ -3,13 +3,30 @@ import java.util.Map;
3 3
4public interface IChannelNode extends Comparable<IChannelNode> { 4public interface IChannelNode extends Comparable<IChannelNode> {
5 enum Direction { 5 enum Direction {
6 INCOMING(0), // Users incoming from outside channel (aka: other channel forwarded this channel's post) 6 INCOMING(1), // Users incoming from outside channel (aka: other channel forwarded this channel's post)
7 OUTGOING(1), // Users outgoing from this channel (aka: this channel forwarded someone else's post) 7 OUTGOING(2), // Users outgoing from this channel (aka: this channel forwarded someone else's post)
8 BOTH(2); // Modify both incoming and outgoing counts at once 8 BOTH(3); // Modify both incoming and outgoing counts at once
9 9
10 private final int val; 10 private final int val;
11 Direction(int val) {this.val = val;} 11 Direction(int val) {this.val = val;}
12 public int getVal() {return this.val;} 12 public int getVal() {return this.val;}
13
14 public interface callback {
15 void cb();
16 }
17 public static void overVals(Map<Direction, callback> cmap, Direction dir) throws IllegalArgumentException {
18 if(cmap == null) throw new IllegalArgumentException("callback map is null");
19 if(dir == null) throw new IllegalArgumentException("dir is null");
20 for(Direction cdir: cmap.keySet()) if(cdir == null) throw new IllegalArgumentException("One of the directions is null");
21 for(callback cb: cmap.values()) if(cb == null) throw new IllegalArgumentException("One of the callbacks is null");
22
23 // For each direction in the map, check that the given direction is gte, and if so run the callback
24 for(Direction cdir: cmap.keySet())
25 if(dir.getVal() >= cdir.getVal())
26 cmap.get(cdir).cb();
27 }
28 // This is hilariously overengineered because java fucking sucks my entire cock and balls
29 // Barely even saves any space too
13 } 30 }
14 31
15 void setConnections(Map<IChannelNode, Integer> conmap, Direction dir); 32 void setConnections(Map<IChannelNode, Integer> conmap, Direction dir);