JAL-2808 revised util.matcher package, 2 filter conditions per feature
[jalview.git] / src / jalview / util / matcher / KeyedMatcherSetI.java
diff --git a/src/jalview/util/matcher/KeyedMatcherSetI.java b/src/jalview/util/matcher/KeyedMatcherSetI.java
new file mode 100644 (file)
index 0000000..09532a4
--- /dev/null
@@ -0,0 +1,58 @@
+package jalview.util.matcher;
+
+import java.util.Iterator;
+import java.util.function.Function;
+
+/**
+ * An interface to describe a set of one or more key-value match conditions,
+ * where all conditions are combined with either AND or OR
+ * 
+ * @author gmcarstairs
+ *
+ */
+public interface KeyedMatcherSetI
+{
+  /**
+   * Answers true if the value provided for this matcher's key passes this
+   * matcher's match condition
+   * 
+   * @param valueProvider
+   * @return
+   */
+  boolean matches(Function<String, String> valueProvider);
+
+  /**
+   * Answers a new object that matches the logical AND of this and m
+   * 
+   * @param m
+   * @return
+   * @throws IllegalStateException
+   *           if an attempt is made to AND to existing OR-ed conditions
+   */
+  KeyedMatcherSetI and(KeyedMatcherI m);
+
+  /**
+   * Answers true if any second condition is AND-ed with this one, false if it
+   * is OR-ed
+   * 
+   * @return
+   */
+  boolean isAnded();
+
+  /**
+   * Answers a new object that matches the logical OR of this and m
+   * 
+   * @param m
+   * @return
+   * @throws IllegalStateException
+   *           if an attempt is made to OR to existing AND-ed conditions
+   */
+  KeyedMatcherSetI or(KeyedMatcherI m);
+
+  /**
+   * Answers an iterator over the combined match conditions
+   * 
+   * @return
+   */
+  Iterator<KeyedMatcherI> getMatchers();
+}