com.alibaba.fastjson2.adapter.jackson.databind.node.FloatNode Maven / Gradle / Ivy
package com.alibaba.fastjson2.adapter.jackson.databind.node;
import com.alibaba.fastjson2.adapter.jackson.core.JsonParser;
import com.alibaba.fastjson2.annotation.JSONField;
public class FloatNode
extends ValueNode {
private float value;
public FloatNode(@JSONField(name = "value", value = true) float value) {
this.value = value;
}
@Override
public JsonParser.NumberType numberType() {
return JsonParser.NumberType.FLOAT;
}
@Override
public final JsonNodeType getNodeType() {
return JsonNodeType.NUMBER;
}
@JSONField(name = "value", value = true)
public float getValue() {
return value;
}
@Override
public String asText() {
return Float.toString(value);
}
@Override
public int asInt(int defaultValue) {
return (int) value;
}
@Override
public long longValue() {
return (long) value;
}
@Override
public int intValue() {
return (int) value;
}
public static FloatNode valueOf(float v) {
return new FloatNode(v);
}
public boolean isFloat() {
return true;
}
public double asDouble() {
return value;
}
}