X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Futil%2Fmatcher%2FCondition.java;fp=src%2Fjalview%2Futil%2Fmatcher%2FCondition.java;h=455f80511c7c9291a328e131d881aa8e2a677f7e;hb=67dbd0072044a077ac43079ea12c8c4803636ee1;hp=0000000000000000000000000000000000000000;hpb=6d06c08f3a378023fe22bd58dceb0dfd58306213;p=jalview.git diff --git a/src/jalview/util/matcher/Condition.java b/src/jalview/util/matcher/Condition.java new file mode 100644 index 0000000..455f805 --- /dev/null +++ b/src/jalview/util/matcher/Condition.java @@ -0,0 +1,57 @@ +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 displayNames = new HashMap<>(); + + private boolean numeric; + + Condition(boolean isNumeric) + { + numeric = isNumeric; + } + + /** + * Answers true if the condition does a numerical comparison, else false + * (string comparison) + * + * @return + */ + public boolean isNumeric() + { + return numeric; + } + + /** + * 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. + * + * @return + */ + @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; + } +}