JAL-2808 update spike to latest
[jalview.git] / src / jalview / util / matcher / Condition.java
1 package jalview.util.matcher;
2
3 import jalview.util.MessageManager;
4
5 /**
6  * An enumeration for binary conditions that a user might choose from when
7  * setting filter or match conditions for values
8  */
9 public enum Condition
10 {
11   Contains(false, true), NotContains(false, true), Matches(false, true),
12   NotMatches(false, true), Present(false, false), NotPresent(false, false),
13   EQ(true, true), NE(true, true), LT(true, true), LE(true, true),
14   GT(true, true), GE(true, true);
15   
16   private boolean numeric;
17
18   private boolean needsAPattern;
19
20   Condition(boolean isNumeric, boolean needsPattern)
21   {
22     numeric = isNumeric;
23     needsAPattern = needsPattern;
24   }
25
26   /**
27    * Answers true if the condition does a numerical comparison, else false
28    * (string comparison)
29    * 
30    * @return
31    */
32   public boolean isNumeric()
33   {
34     return numeric;
35   }
36
37   /**
38    * Answers true if the condition requires a pattern to compare against, else
39    * false
40    * 
41    * @return
42    */
43   public boolean needsAPattern()
44   {
45     return needsAPattern;
46   }
47
48   /**
49    * Answers a display name for the match condition, suitable for showing in
50    * drop-down menus. The value may be internationalized using the resource key
51    * "label.matchCondition_" with the enum name appended.
52    * 
53    * @return
54    */
55   @Override
56   public String toString()
57   {
58     return MessageManager.getStringOrReturn("label.matchCondition_",
59             name());
60   }
61 }