com.jsoniter.any.LongAny Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jsoniter Show documentation
Show all versions of jsoniter Show documentation
jsoniter (json-iterator) is fast and flexible JSON parser available in Java and Go
The newest version!
package com.jsoniter.any;
import com.jsoniter.ValueType;
import com.jsoniter.output.JsonStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;
class LongAny extends Any {
private long val;
public LongAny(long val) {
this.val = val;
}
@Override
public ValueType valueType() {
return ValueType.NUMBER;
}
@Override
public Object object() {
return val;
}
@Override
public boolean toBoolean() {
return val != 0;
}
@Override
public int toInt() {
return (int) val;
}
@Override
public long toLong() {
return val;
}
@Override
public float toFloat() {
return val;
}
@Override
public double toDouble() {
return val;
}
@Override
public BigInteger toBigInteger() {
return BigInteger.valueOf(val);
}
@Override
public BigDecimal toBigDecimal() {
return BigDecimal.valueOf(val);
}
@Override
public String toString() {
return String.valueOf(val);
}
public Any set(long newVal) {
this.val = newVal;
return this;
}
@Override
public void writeTo(JsonStream stream) throws IOException {
stream.writeVal(val);
}
}