org.dominokit.domino.ui.forms.FloatBox Maven / Gradle / Ivy
package org.dominokit.domino.ui.forms;
import elemental2.core.JsNumber;
import org.dominokit.domino.ui.utils.ElementUtil;
public class FloatBox extends NumberBox {
public static FloatBox create() {
return new FloatBox();
}
public static FloatBox create(String label) {
return new FloatBox(label);
}
public FloatBox() {
this("");
}
public FloatBox(String label) {
super(label);
ElementUtil.decimalOnly(this);
}
@Override
protected void clearValue() {
value(0.0F);
}
@Override
protected Float parseValue(String value) {
double dValue = getNumberFormat().parse(value);
double maxFloat=new Double(getMaxValue());
if(dValue > maxFloat){
throw new NumberFormatException("Exceeded maximum value");
}
return new Double(dValue).floatValue();
}
@Override
protected boolean isExceedMaxValue(Float maxValue, Float value) {
return value > maxValue;
}
@Override
protected boolean isLowerThanMinValue(Float minValue, Float value) {
return value < minValue;
}
@Override
protected Float defaultMaxValue() {
return (float) JsNumber.POSITIVE_INFINITY;
}
@Override
protected Float defaultMinValue() {
return (float) JsNumber.NEGATIVE_INFINITY;
}
}