JAL-2808 update spike to latest
[jalview.git] / src / jalview / util / matcher / Condition.java
index 455f805..3047802 100644 (file)
@@ -2,25 +2,25 @@ package jalview.util.matcher;
 
 import jalview.util.MessageManager;
 
-import java.util.HashMap;
-import java.util.Map;
-
 /**
  * An enumeration for binary conditions that a user might choose from when
  * setting filter or match conditions for values
  */
 public enum Condition
 {
-  Contains(false), NotContains(false), Matches(false), NotMatches(false),
-  EQ(true), NE(true), LT(true), LE(true), GT(true), GE(true);
-
-  private static Map<Condition, String> displayNames = new HashMap<>();
+  Contains(false, true), NotContains(false, true), Matches(false, true),
+  NotMatches(false, true), Present(false, false), NotPresent(false, false),
+  EQ(true, true), NE(true, true), LT(true, true), LE(true, true),
+  GT(true, true), GE(true, true);
   
   private boolean numeric;
 
-  Condition(boolean isNumeric)
+  private boolean needsAPattern;
+
+  Condition(boolean isNumeric, boolean needsPattern)
   {
     numeric = isNumeric;
+    needsAPattern = needsPattern;
   }
 
   /**
@@ -35,6 +35,17 @@ public enum Condition
   }
 
   /**
+   * Answers true if the condition requires a pattern to compare against, else
+   * false
+   * 
+   * @return
+   */
+  public boolean needsAPattern()
+  {
+    return needsAPattern;
+  }
+
+  /**
    * Answers a display name for the match condition, suitable for showing in
    * drop-down menus. The value may be internationalized using the resource key
    * "label.matchCondition_" with the enum name appended.
@@ -44,14 +55,7 @@ public enum Condition
   @Override
   public String toString()
   {
-    String name = displayNames.get(this);
-    if (name != null)
-    {
-      return name;
-    }
-    name = MessageManager
-            .getStringOrReturn("label.matchCondition_", name());
-    displayNames.put(this, name);
-    return name;
+    return MessageManager.getStringOrReturn("label.matchCondition_",
+            name());
   }
 }