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