1 package edu.uci.iotproject.detection;
3 import org.pcap4j.core.PcapPacket;
6 import java.util.Objects;
9 * TODO add class documentation.
11 * @author Janus Varmarken
13 abstract public class AbstractClusterMatcher {
15 protected final List<List<PcapPacket>> mCluster;
18 protected AbstractClusterMatcher(List<List<PcapPacket>> cluster) {
19 // ===================== PRECONDITION SECTION =====================
20 cluster = Objects.requireNonNull(cluster, "cluster cannot be null");
21 if (cluster.isEmpty() || cluster.stream().anyMatch(inner -> inner.isEmpty())) {
22 throw new IllegalArgumentException("cluster is empty (or contains an empty inner List)");
24 mCluster = pruneCluster(cluster);
28 * Allows subclasses to specify how to prune input cluster provided to the constructor.
29 * @param cluster The input cluster provided to the constructor.
30 * @return The pruned cluster to use in place of the input cluster.
32 abstract protected List<List<PcapPacket>> pruneCluster(List<List<PcapPacket>> cluster);
34 // TODO: move Direction outside Conversation so that this is less confusing.
35 // abstract protected Conversation.Direction[] getPacketDirections(List<PcapPacket> packets);