25dc96ea9075e559c7df7f62c9b11660534496f7
[jalview.git] / src / jalview / util / matcher / KeyedMatcherSetI.java
1 package jalview.util.matcher;
2
3 import java.util.function.Function;
4
5 /**
6  * An interface to describe a set of one or more key-value match conditions,
7  * where all conditions are combined with either AND or OR
8  * 
9  * @author gmcarstairs
10  *
11  */
12 public interface KeyedMatcherSetI
13 {
14   /**
15    * Answers true if the value provided for this matcher's key passes this
16    * matcher's match condition
17    * 
18    * @param valueProvider
19    * @return
20    */
21   boolean matches(Function<String, String> valueProvider);
22
23   /**
24    * Answers a new object that matches the logical AND of this and m
25    * 
26    * @param m
27    * @return
28    * @throws IllegalStateException
29    *           if an attempt is made to AND to existing OR-ed conditions
30    */
31   KeyedMatcherSetI and(KeyedMatcherI m);
32
33   /**
34    * Answers true if any second condition is AND-ed with this one, false if it
35    * is OR-ed
36    * 
37    * @return
38    */
39   boolean isAnded();
40
41   /**
42    * Answers a new object that matches the logical OR of this and m
43    * 
44    * @param m
45    * @return
46    * @throws IllegalStateException
47    *           if an attempt is made to OR to existing AND-ed conditions
48    */
49   KeyedMatcherSetI or(KeyedMatcherI m);
50
51   /**
52    * Answers an iterator over the combined match conditions
53    * 
54    * @return
55    */
56   Iterable<KeyedMatcherI> getMatchers();
57
58   /**
59    * Answers true if this object contains no conditions
60    * 
61    * @return
62    */
63   boolean isEmpty();
64 }