org.sql2o.converters.BigDecimalConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of anima Show documentation
Show all versions of anima Show documentation
Operate the database like a stream
package org.sql2o.converters;
import java.math.BigDecimal;
/**
* Used by sql2o to convert a value from the database into a {@link BigDecimal}.
*/
public class BigDecimalConverter extends NumberConverter{
public BigDecimalConverter() {
super(false);
}
@Override
protected BigDecimal convertNumberValue(Number val) {
if (val instanceof BigDecimal){
return (BigDecimal)val;
}
else{
return BigDecimal.valueOf(val.doubleValue());
}
}
@Override
protected BigDecimal convertStringValue(String val) {
return BigDecimal.valueOf(Double.parseDouble(val));
}
@Override
protected String getTypeDescription() {
return BigDecimal.class.toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy