Clover icon

jalviewX

  1. Project Clover database Wed Oct 31 2018 15:13:58 GMT
  2. Package jalview.util.matcher

File Condition.java

 

Coverage histogram

../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

2
11
6
1
102
49
7
0.64
1.83
6
1.17

Classes

Class Line # Actions
Condition 9 11 7 0
1.0100%
 

Contributing tests

This file is covered by 38 tests. .

Source view

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, "Contains"),
12    NotContains(false, true, "NotContains"), Matches(false, true, "Matches"),
13    NotMatches(false, true, "NotMatches"), Present(false, false, "Present"),
14    NotPresent(false, false, "NotPresent"), EQ(true, true, "EQ"),
15    NE(true, true, "NE"), LT(true, true, "LT"), LE(true, true, "LE"),
16    GT(true, true, "GT"), GE(true, true, "GE");
17   
18    private boolean numeric;
19   
20    private boolean needsAPattern;
21   
22    /*
23    * value used to save a Condition to the
24    * Jalview project file or restore it from project;
25    * it should not be changed even if enum names change in future
26    */
27    private String stableName;
28   
29    /**
30    * Answers the enum value whose 'stable name' matches the argument (not case
31    * sensitive), or null if no match
32    *
33    * @param stableName
34    * @return
35    */
 
36  70 toggle public static Condition fromString(String stableName)
37    {
38  70 for (Condition c : values())
39    {
40  457 if (c.stableName.equalsIgnoreCase(stableName))
41    {
42  66 return c;
43    }
44    }
45  4 return null;
46    }
47   
48    /**
49    * Constructor
50    *
51    * @param isNumeric
52    * @param needsPattern
53    * @param stablename
54    */
 
55  12 toggle Condition(boolean isNumeric, boolean needsPattern, String stablename)
56    {
57  12 numeric = isNumeric;
58  12 needsAPattern = needsPattern;
59  12 stableName = stablename;
60    }
61   
62    /**
63    * Answers true if the condition does a numerical comparison, else false
64    * (string comparison)
65    *
66    * @return
67    */
 
68  414 toggle public boolean isNumeric()
69    {
70  414 return numeric;
71    }
72   
73    /**
74    * Answers true if the condition requires a pattern to compare against, else
75    * false
76    *
77    * @return
78    */
 
79  54 toggle public boolean needsAPattern()
80    {
81  54 return needsAPattern;
82    }
83   
 
84  68 toggle public String getStableName()
85    {
86  68 return stableName;
87    }
88   
89    /**
90    * Answers a display name for the match condition, suitable for showing in
91    * drop-down menus. The value may be internationalized using the resource key
92    * "label.matchCondition_" with the enum name appended.
93    *
94    * @return
95    */
 
96  29 toggle @Override
97    public String toString()
98    {
99  29 return MessageManager.getStringOrReturn("label.matchCondition_",
100    name());
101    }
102    }