| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
package jalview.ws.params.simple; |
| 22 |
|
|
| 23 |
|
import jalview.ws.params.OptionI; |
| 24 |
|
|
| 25 |
|
import java.net.URL; |
| 26 |
|
import java.util.ArrayList; |
| 27 |
|
import java.util.List; |
| 28 |
|
import static java.util.Objects.requireNonNull; |
| 29 |
|
|
| |
|
| 40% |
Uncovered Elements: 54 (90) |
Complexity: 30 |
Complexity Density: 0.58 |
|
| 30 |
|
public class Option implements OptionI |
| 31 |
|
{ |
| 32 |
|
|
| 33 |
|
|
| 34 |
|
|
| 35 |
|
@author |
| 36 |
|
|
| 37 |
|
|
| |
|
| 90% |
Uncovered Elements: 2 (20) |
Complexity: 10 |
Complexity Density: 1 |
|
| 38 |
|
public static class Builder |
| 39 |
|
{ |
| 40 |
|
protected String name = null; |
| 41 |
|
|
| 42 |
|
protected String label = null; |
| 43 |
|
|
| 44 |
|
protected String description = ""; |
| 45 |
|
|
| 46 |
|
protected boolean required = false; |
| 47 |
|
|
| 48 |
|
protected String defaultValue = null; |
| 49 |
|
|
| 50 |
|
protected String value = null; |
| 51 |
|
|
| 52 |
|
protected List<String> possibleValues = null; |
| 53 |
|
|
| 54 |
|
protected List<String> displayValues = null; |
| 55 |
|
|
| 56 |
|
protected URL detailsUrl = null; |
| 57 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 58 |
12775 |
public void setName(String name)... |
| 59 |
|
{ |
| 60 |
12775 |
this.name = name; |
| 61 |
|
} |
| 62 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 63 |
12775 |
public void setLabel(String label)... |
| 64 |
|
{ |
| 65 |
12775 |
this.label = label; |
| 66 |
|
} |
| 67 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 68 |
10903 |
public void setDescription(String description)... |
| 69 |
|
{ |
| 70 |
10903 |
this.description = description; |
| 71 |
|
} |
| 72 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 73 |
10903 |
public void setRequired(boolean required)... |
| 74 |
|
{ |
| 75 |
10903 |
this.required = required; |
| 76 |
|
} |
| 77 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 78 |
7960 |
public void setDefaultValue(String defaultValue)... |
| 79 |
|
{ |
| 80 |
7960 |
this.defaultValue = defaultValue; |
| 81 |
|
} |
| 82 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 83 |
4943 |
public void setValue(String value)... |
| 84 |
|
{ |
| 85 |
4943 |
this.value = value; |
| 86 |
|
} |
| 87 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 88 |
3047 |
public void setPossibleValues(List<String> possibleValues)... |
| 89 |
|
{ |
| 90 |
3047 |
this.possibleValues = possibleValues; |
| 91 |
|
} |
| 92 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 93 |
30 |
public void setDisplayValues(List<String> displayValues)... |
| 94 |
|
{ |
| 95 |
30 |
this.displayValues = displayValues; |
| 96 |
|
} |
| 97 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 98 |
10893 |
public void setDetailsUrl(URL detailsUrl)... |
| 99 |
|
{ |
| 100 |
10893 |
this.detailsUrl = detailsUrl; |
| 101 |
|
} |
| 102 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 103 |
0 |
public Option build()... |
| 104 |
|
{ |
| 105 |
0 |
return new Option(this); |
| 106 |
|
} |
| 107 |
|
} |
| 108 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 109 |
0 |
public static Builder newBuilder()... |
| 110 |
|
{ |
| 111 |
0 |
return new Builder(); |
| 112 |
|
} |
| 113 |
|
|
| 114 |
|
String name; |
| 115 |
|
|
| 116 |
|
String label; |
| 117 |
|
|
| 118 |
|
|
| 119 |
|
|
| 120 |
|
|
| 121 |
|
String value; |
| 122 |
|
|
| 123 |
|
|
| 124 |
|
|
| 125 |
|
|
| 126 |
|
String defvalue; |
| 127 |
|
|
| 128 |
|
String description; |
| 129 |
|
|
| 130 |
|
List<String> possibleVals; |
| 131 |
|
|
| 132 |
|
|
| 133 |
|
|
| 134 |
|
|
| 135 |
|
List<String> displayVals; |
| 136 |
|
|
| 137 |
|
boolean required; |
| 138 |
|
|
| 139 |
|
URL fdetails; |
| 140 |
|
|
| |
|
| 85.2% |
Uncovered Elements: 4 (27) |
Complexity: 8 |
Complexity Density: 0.47 |
|
| 141 |
12671 |
protected Option(Builder builder)... |
| 142 |
|
{ |
| 143 |
12671 |
requireNonNull(builder.name); |
| 144 |
12671 |
name = builder.name; |
| 145 |
12671 |
label = builder.label != null ? builder.label : name; |
| 146 |
12671 |
description = builder.description; |
| 147 |
12671 |
required = builder.required; |
| 148 |
12671 |
defvalue = builder.defaultValue; |
| 149 |
12671 |
value = builder.value; |
| 150 |
12671 |
if (builder.possibleValues != null) |
| 151 |
3047 |
possibleVals = new ArrayList<>(builder.possibleValues); |
| 152 |
12671 |
if (builder.displayValues != null) |
| 153 |
30 |
displayVals = new ArrayList<>(builder.displayValues); |
| 154 |
|
else |
| 155 |
12641 |
displayVals = possibleVals; |
| 156 |
12671 |
if (possibleVals == null && displayVals != null) |
| 157 |
0 |
throw new IllegalArgumentException( |
| 158 |
|
"cannot use displayValues if possibleValues is null"); |
| 159 |
12671 |
if (possibleVals != null && possibleVals.size() != displayVals.size()) |
| 160 |
0 |
throw new IllegalArgumentException( |
| 161 |
|
"displayValues size does not match possibleValues"); |
| 162 |
12671 |
fdetails = builder.detailsUrl; |
| 163 |
|
} |
| 164 |
|
|
| 165 |
|
|
| 166 |
|
|
| 167 |
|
|
| 168 |
|
@param |
| 169 |
|
|
| |
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 2 |
Complexity Density: 0.22 |
|
| 170 |
0 |
public Option(Option opt)... |
| 171 |
|
{ |
| 172 |
0 |
name = opt.name; |
| 173 |
0 |
label = opt.label; |
| 174 |
0 |
value = opt.value; |
| 175 |
0 |
defvalue = opt.defvalue; |
| 176 |
0 |
description = opt.description; |
| 177 |
0 |
if (opt.possibleVals != null) |
| 178 |
|
{ |
| 179 |
0 |
possibleVals = new ArrayList<>(opt.possibleVals); |
| 180 |
|
} |
| 181 |
0 |
required = opt.required; |
| 182 |
|
|
| 183 |
0 |
fdetails = opt.fdetails; |
| 184 |
|
} |
| 185 |
|
|
| |
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 186 |
0 |
public Option()... |
| 187 |
|
{ |
| 188 |
|
} |
| 189 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 190 |
0 |
public Option(String name, String description, String label, boolean isrequired,... |
| 191 |
|
String defValue, String val, List<String> possibleVals, URL fdetails) |
| 192 |
|
{ |
| 193 |
0 |
this(name, description, isrequired, defValue, val, possibleVals, fdetails); |
| 194 |
0 |
this.label = label; |
| 195 |
|
} |
| 196 |
|
|
| 197 |
|
|
| 198 |
|
|
| 199 |
|
|
| 200 |
|
@param |
| 201 |
|
@param |
| 202 |
|
@param |
| 203 |
|
@param |
| 204 |
|
@param |
| 205 |
|
@param |
| 206 |
|
@param |
| 207 |
|
|
| |
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 3 |
Complexity Density: 0.3 |
|
| 208 |
0 |
public Option(String name2, String description2, boolean isrequired,... |
| 209 |
|
String defValue, String val, List<String> possibleVals, |
| 210 |
|
List<String> displayNames, URL fdetails) |
| 211 |
|
{ |
| 212 |
0 |
name = name2; |
| 213 |
0 |
description = description2; |
| 214 |
0 |
this.value = val; |
| 215 |
0 |
this.required = isrequired; |
| 216 |
0 |
this.defvalue = defValue; |
| 217 |
0 |
if (possibleVals != null) |
| 218 |
|
{ |
| 219 |
0 |
this.possibleVals = new ArrayList<>(possibleVals); |
| 220 |
|
} |
| 221 |
0 |
if (displayNames != null) |
| 222 |
|
{ |
| 223 |
0 |
this.displayVals = new ArrayList<>(displayNames); |
| 224 |
|
} |
| 225 |
0 |
this.fdetails = fdetails; |
| 226 |
|
} |
| 227 |
|
|
| 228 |
|
|
| 229 |
|
|
| 230 |
|
|
| 231 |
|
@param |
| 232 |
|
@param |
| 233 |
|
@param |
| 234 |
|
@param |
| 235 |
|
@param |
| 236 |
|
@param |
| 237 |
|
@param |
| 238 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 239 |
0 |
public Option(String name2, String description2, boolean isrequired,... |
| 240 |
|
String defValue, String val, List<String> possibleVals, |
| 241 |
|
URL fdetails) |
| 242 |
|
{ |
| 243 |
0 |
this(name2, description2, isrequired, defValue, val, possibleVals, null, |
| 244 |
|
fdetails); |
| 245 |
|
} |
| 246 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 247 |
0 |
@Override... |
| 248 |
|
public OptionI copy() |
| 249 |
|
{ |
| 250 |
0 |
Option opt = new Option(this); |
| 251 |
0 |
return opt; |
| 252 |
|
} |
| 253 |
|
|
| 254 |
|
|
| 255 |
|
|
| 256 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 257 |
0 |
@Override... |
| 258 |
|
public String toString() |
| 259 |
|
{ |
| 260 |
0 |
return this.getClass().getName() + ":" + name; |
| 261 |
|
} |
| 262 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 263 |
3 |
@Override... |
| 264 |
|
public String getName() |
| 265 |
|
{ |
| 266 |
3 |
return name; |
| 267 |
|
} |
| 268 |
|
|
| |
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
| 269 |
3 |
@Override... |
| 270 |
|
public String getLabel() |
| 271 |
|
{ |
| 272 |
3 |
return label != null ? label : name; |
| 273 |
|
} |
| 274 |
|
|
| |
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
| 275 |
3 |
@Override... |
| 276 |
|
public String getValue() |
| 277 |
|
{ |
| 278 |
3 |
return value == null ? defvalue : value; |
| 279 |
|
} |
| 280 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 281 |
0 |
@Override... |
| 282 |
|
public void setValue(String selectedItem) |
| 283 |
|
{ |
| 284 |
0 |
value = selectedItem; |
| 285 |
|
} |
| 286 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 287 |
0 |
@Override... |
| 288 |
|
public URL getFurtherDetails() |
| 289 |
|
{ |
| 290 |
0 |
return fdetails; |
| 291 |
|
} |
| 292 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 293 |
3 |
@Override... |
| 294 |
|
public boolean isRequired() |
| 295 |
|
{ |
| 296 |
3 |
return required; |
| 297 |
|
} |
| 298 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 299 |
3 |
@Override... |
| 300 |
|
public String getDescription() |
| 301 |
|
{ |
| 302 |
3 |
return description; |
| 303 |
|
} |
| 304 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 305 |
0 |
@Override... |
| 306 |
|
public List<String> getPossibleValues() |
| 307 |
|
{ |
| 308 |
0 |
return possibleVals; |
| 309 |
|
} |
| 310 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 311 |
0 |
@Override... |
| 312 |
|
public List<String> getDisplayNames() |
| 313 |
|
{ |
| 314 |
0 |
return displayVals; |
| 315 |
|
} |
| 316 |
|
} |