Clover icon

Coverage Report

  1. Project Clover database Wed Nov 13 2024 16:21:17 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
122
49
7
0.64
1.83
6
1.17

Classes

Class Line # Actions
Condition 29 11 7
1.0100%
 

Contributing tests

This file is covered by 42 tests. .

Source view

1    /*
2    * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3    * Copyright (C) $$Year-Rel$$ The Jalview Authors
4    *
5    * This file is part of Jalview.
6    *
7    * Jalview is free software: you can redistribute it and/or
8    * modify it under the terms of the GNU General Public License
9    * as published by the Free Software Foundation, either version 3
10    * of the License, or (at your option) any later version.
11    *
12    * Jalview is distributed in the hope that it will be useful, but
13    * WITHOUT ANY WARRANTY; without even the implied warranty
14    * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15    * PURPOSE. See the GNU General Public License for more details.
16    *
17    * You should have received a copy of the GNU General Public License
18    * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19    * The Jalview Authors are detailed in the 'AUTHORS' file.
20    */
21    package jalview.util.matcher;
22   
23    import jalview.util.MessageManager;
24   
25    /**
26    * An enumeration for binary conditions that a user might choose from when
27    * setting filter or match conditions for values
28    */
 
29    public enum Condition
30    {
31    Contains(false, true, "Contains"),
32    NotContains(false, true, "NotContains"), Matches(false, true, "Matches"),
33    NotMatches(false, true, "NotMatches"), Present(false, false, "Present"),
34    NotPresent(false, false, "NotPresent"), EQ(true, true, "EQ"),
35    NE(true, true, "NE"), LT(true, true, "LT"), LE(true, true, "LE"),
36    GT(true, true, "GT"), GE(true, true, "GE");
37   
38    private boolean numeric;
39   
40    private boolean needsAPattern;
41   
42    /*
43    * value used to save a Condition to the
44    * Jalview project file or restore it from project;
45    * it should not be changed even if enum names change in future
46    */
47    private String stableName;
48   
49    /**
50    * Answers the enum value whose 'stable name' matches the argument (not case
51    * sensitive), or null if no match
52    *
53    * @param stableName
54    * @return
55    */
 
56  70 toggle public static Condition fromString(String stableName)
57    {
58  70 for (Condition c : values())
59    {
60  457 if (c.stableName.equalsIgnoreCase(stableName))
61    {
62  66 return c;
63    }
64    }
65  4 return null;
66    }
67   
68    /**
69    * Constructor
70    *
71    * @param isNumeric
72    * @param needsPattern
73    * @param stablename
74    */
 
75  12 toggle Condition(boolean isNumeric, boolean needsPattern, String stablename)
76    {
77  12 numeric = isNumeric;
78  12 needsAPattern = needsPattern;
79  12 stableName = stablename;
80    }
81   
82    /**
83    * Answers true if the condition does a numerical comparison, else false
84    * (string comparison)
85    *
86    * @return
87    */
 
88  401 toggle public boolean isNumeric()
89    {
90  401 return numeric;
91    }
92   
93    /**
94    * Answers true if the condition requires a pattern to compare against, else
95    * false
96    *
97    * @return
98    */
 
99  55 toggle public boolean needsAPattern()
100    {
101  55 return needsAPattern;
102    }
103   
 
104  69 toggle public String getStableName()
105    {
106  69 return stableName;
107    }
108   
109    /**
110    * Answers a display name for the match condition, suitable for showing in
111    * drop-down menus. The value may be internationalized using the resource key
112    * "label.matchCondition_" with the enum name appended.
113    *
114    * @return
115    */
 
116  30 toggle @Override
117    public String toString()
118    {
119  30 return MessageManager.getStringOrReturn("label.matchCondition_",
120    name());
121    }
122    }