
com.github.smartbuf.converter.codec.MathCodec Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of smartbuf Show documentation
Show all versions of smartbuf Show documentation
SmartBuf, is a cross-language serialization and deserialization framework, and it has
high performance and compression ratio like protobuf, high compatibility and scalability like json.
The newest version!
package com.github.smartbuf.converter.codec;
import com.github.smartbuf.converter.Converter;
import com.github.smartbuf.converter.Codec;
import java.math.BigDecimal;
import java.math.BigInteger;
/**
* Codec for java.math package, include BigDecimal and BigInteger.
*
* @author sulin
* @since 2019-07-25 12:17:16
*/
public final class MathCodec extends Codec {
@Converter
public BigDecimal toBigDecimal(String s) {
return new BigDecimal(s);
}
@Converter
public String toString(BigDecimal bd) {
return bd.toPlainString();
}
@Converter
public BigInteger toBigInteger(String s) {
return new BigInteger(s);
}
@Converter
public String toString(BigInteger bi) {
return bi.toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy