| 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.ArgumentI; |
| 24 |
|
import jalview.ws.params.ParameterI; |
| 25 |
|
import jalview.ws.params.ValueConstrainI; |
| 26 |
|
|
| 27 |
|
|
| 28 |
|
@author |
| 29 |
|
|
| 30 |
|
|
| |
|
| 52.4% |
Uncovered Elements: 20 (42) |
Complexity: 16 |
Complexity Density: 0.7 |
|
| 31 |
|
public class IntegerParameter extends Option implements ParameterI |
| 32 |
|
{ |
| |
|
| 86.2% |
Uncovered Elements: 4 (29) |
Complexity: 12 |
Complexity Density: 0.92 |
|
| 33 |
|
public static class Builder extends Option.Builder |
| 34 |
|
{ |
| 35 |
|
|
| 36 |
|
protected int min = Integer.MAX_VALUE; |
| 37 |
|
|
| 38 |
|
protected int max = Integer.MIN_VALUE; |
| 39 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 40 |
0 |
@Override... |
| 41 |
|
public void setDefaultValue(String defaultValue) |
| 42 |
|
{ |
| 43 |
0 |
throw new UnsupportedOperationException(); |
| 44 |
|
} |
| 45 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 46 |
3014 |
public void setDefaultValue(Integer defaultValue)... |
| 47 |
|
{ |
| 48 |
3014 |
if (defaultValue != null) |
| 49 |
3008 |
super.setDefaultValue(defaultValue.toString()); |
| 50 |
|
else |
| 51 |
6 |
super.setDefaultValue(null); |
| 52 |
|
} |
| 53 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 54 |
0 |
@Override... |
| 55 |
|
public void setValue(String value) |
| 56 |
|
{ |
| 57 |
0 |
throw new UnsupportedOperationException(); |
| 58 |
|
} |
| 59 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 60 |
3014 |
public void setValue(Integer value)... |
| 61 |
|
{ |
| 62 |
3014 |
if (value != null) |
| 63 |
10 |
super.setValue(value.toString()); |
| 64 |
|
else |
| 65 |
3004 |
super.setValue(null); |
| 66 |
|
} |
| 67 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
| 68 |
3004 |
public void setMin(Integer min)... |
| 69 |
|
{ |
| 70 |
3004 |
this.min = min != null ? min : Integer.MAX_VALUE; |
| 71 |
|
} |
| 72 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
| 73 |
3004 |
public void setMax(Integer max)... |
| 74 |
|
{ |
| 75 |
3004 |
this.max = max != null ? max : Integer.MIN_VALUE; |
| 76 |
|
} |
| 77 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 78 |
3004 |
public void setBounds(Integer min, Integer max)... |
| 79 |
|
{ |
| 80 |
3004 |
setMin(min); |
| 81 |
3004 |
setMax(max); |
| 82 |
|
} |
| 83 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 84 |
3014 |
public IntegerParameter build()... |
| 85 |
|
{ |
| 86 |
3014 |
return new IntegerParameter(this); |
| 87 |
|
} |
| 88 |
|
} |
| 89 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 90 |
3014 |
public static Builder newBuilder()... |
| 91 |
|
{ |
| 92 |
3014 |
return new Builder(); |
| 93 |
|
} |
| 94 |
|
|
| 95 |
|
int defval; |
| 96 |
|
|
| 97 |
|
int min; |
| 98 |
|
|
| 99 |
|
int max; |
| 100 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 101 |
3 |
@Override... |
| 102 |
|
public ValueConstrainI getValidValue() |
| 103 |
|
{ |
| 104 |
3 |
return new ValueConstrainI() |
| 105 |
|
{ |
| 106 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 107 |
1 |
@Override... |
| 108 |
|
public ValueType getType() |
| 109 |
|
{ |
| 110 |
1 |
return ValueType.Integer; |
| 111 |
|
} |
| 112 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
| 113 |
2 |
@Override... |
| 114 |
|
public Number getMin() |
| 115 |
|
{ |
| 116 |
2 |
return min < max ? min : null; |
| 117 |
|
} |
| 118 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
| 119 |
2 |
@Override... |
| 120 |
|
public Number getMax() |
| 121 |
|
{ |
| 122 |
2 |
return min < max ? max : null; |
| 123 |
|
} |
| 124 |
|
}; |
| 125 |
|
} |
| 126 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 127 |
3014 |
protected IntegerParameter(Builder builder)... |
| 128 |
|
{ |
| 129 |
3014 |
super(builder); |
| 130 |
3014 |
min = builder.min; |
| 131 |
3014 |
max = builder.max; |
| 132 |
3014 |
if (defvalue != null) |
| 133 |
3008 |
defval = Integer.parseInt(defvalue); |
| 134 |
|
} |
| 135 |
|
|
| |
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 136 |
0 |
public IntegerParameter(IntegerParameter parm)... |
| 137 |
|
{ |
| 138 |
0 |
super(parm); |
| 139 |
0 |
max = parm.max; |
| 140 |
0 |
min = parm.min; |
| 141 |
|
} |
| 142 |
|
|
| |
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 143 |
0 |
public IntegerParameter(String name, String description, boolean required,... |
| 144 |
|
int defValue, int min, int max) |
| 145 |
|
{ |
| 146 |
0 |
super(name, description, required, String.valueOf(defValue), null, null, |
| 147 |
|
null); |
| 148 |
0 |
defval = defValue; |
| 149 |
0 |
this.min = min; |
| 150 |
0 |
this.max = max; |
| 151 |
|
} |
| 152 |
|
|
| |
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 153 |
0 |
public IntegerParameter(String name, String description, boolean required,... |
| 154 |
|
int defValue, int value, int min, int max) |
| 155 |
|
{ |
| 156 |
0 |
super(name, description, required, String.valueOf(defValue), |
| 157 |
|
String.valueOf(value), null, null); |
| 158 |
0 |
defval = defValue; |
| 159 |
0 |
this.min = min; |
| 160 |
0 |
this.max = max; |
| 161 |
|
} |
| 162 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 163 |
0 |
@Override... |
| 164 |
|
public IntegerParameter copy() |
| 165 |
|
{ |
| 166 |
0 |
return new IntegerParameter(this); |
| 167 |
|
} |
| 168 |
|
|
| 169 |
|
|
| 170 |
|
|
| 171 |
|
|
| 172 |
|
@param |
| 173 |
|
@return |
| 174 |
|
|
| |
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 3 |
Complexity Density: 3 |
|
| 175 |
0 |
public static Integer parseInt(ArgumentI arg)... |
| 176 |
|
{ |
| 177 |
0 |
return arg.getValue() != null && !arg.getValue().isEmpty() ? |
| 178 |
|
Integer.parseInt(arg.getValue()) : null; |
| 179 |
|
} |
| 180 |
|
|
| 181 |
|
} |