1 package jalview.ws.params.simple;
3 import jalview.ws.params.ParameterI;
4 import jalview.ws.params.ValueConstrainI;
11 public class DoubleParameter extends Option implements ParameterI
13 public static class Builder extends Option.Builder
15 // setting them the opposite way disables limits until both are set.
16 protected double min = Double.POSITIVE_INFINITY;
18 protected double max = Double.NEGATIVE_INFINITY;
21 * Setting string on double parameter is not allowed, use
22 * {@link #setValue(Double)} instead.
25 public void setValue(String value)
27 throw new UnsupportedOperationException();
30 public void setValue(Double value)
33 super.setValue(value.toString());
39 * Setting string on double parameter is not allowed, use
40 * {@link #setDefaultValue(Double)} instead.
43 public void setDefaultValue(String defaultValue)
45 throw new UnsupportedOperationException();
48 public void setDefaultValue(Double defaultValue)
50 if (defaultValue != null)
51 super.setDefaultValue(defaultValue.toString());
53 super.setDefaultValue(null);
56 public void setMin(Double min)
58 this.min = min != null ? min : Double.POSITIVE_INFINITY;
61 public void setMax(Double max)
63 this.max = max != null ? max : Double.NEGATIVE_INFINITY;
66 public void setBounds(Double min, Double max)
72 public DoubleParameter build()
74 return new DoubleParameter(this);
78 public static Builder newBuilder()
90 public ValueConstrainI getValidValue()
92 return new ValueConstrainI()
95 public ValueType getType()
97 return ValueType.Double;
101 public Number getMin()
103 return min < max ? min : null;
107 public Number getMax()
109 return min < max ? max : null;
114 protected DoubleParameter(Builder builder)
117 this.min = builder.min;
118 this.max = builder.max;
119 if (defvalue != null)
120 defval = Double.parseDouble(defvalue);
123 public DoubleParameter(DoubleParameter parm)
130 public DoubleParameter(String name, String description, boolean required,
131 Double defValue, double min, double max)
133 super(name, description, required, String.valueOf(defValue), null, null,
140 public DoubleParameter(String name, String description, boolean required,
141 Double defValue, Double value, double min, double max)
143 super(name, description, required, String.valueOf(defValue),
144 String.valueOf(value), null, null);
151 public DoubleParameter copy()
153 return new DoubleParameter(this);