From 82c6f12de286db3c89758f201f619a63accf17f4 Mon Sep 17 00:00:00 2001 From: "@syxhe" Date: Thu, 2 Oct 2025 16:21:29 -0500 Subject: Begin the over-engineering process --- src/main/java/IChannelNode.java | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'src/main/java/IChannelNode.java') 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; public interface IChannelNode extends Comparable { enum Direction { - INCOMING(0), // Users incoming from outside channel (aka: other channel forwarded this channel's post) - OUTGOING(1), // Users outgoing from this channel (aka: this channel forwarded someone else's post) - BOTH(2); // Modify both incoming and outgoing counts at once + INCOMING(1), // Users incoming from outside channel (aka: other channel forwarded this channel's post) + OUTGOING(2), // Users outgoing from this channel (aka: this channel forwarded someone else's post) + BOTH(3); // Modify both incoming and outgoing counts at once private final int val; Direction(int val) {this.val = val;} public int getVal() {return this.val;} + + public interface callback { + void cb(); + } + public static void overVals(Map cmap, Direction dir) throws IllegalArgumentException { + if(cmap == null) throw new IllegalArgumentException("callback map is null"); + if(dir == null) throw new IllegalArgumentException("dir is null"); + for(Direction cdir: cmap.keySet()) if(cdir == null) throw new IllegalArgumentException("One of the directions is null"); + for(callback cb: cmap.values()) if(cb == null) throw new IllegalArgumentException("One of the callbacks is null"); + + // For each direction in the map, check that the given direction is gte, and if so run the callback + for(Direction cdir: cmap.keySet()) + if(dir.getVal() >= cdir.getVal()) + cmap.get(cdir).cb(); + } + // This is hilariously overengineered because java fucking sucks my entire cock and balls + // Barely even saves any space too } void setConnections(Map conmap, Direction dir); -- cgit v1.2.3