com.gh.mygreen.xlsmapper.cellconvert.converter.ByteCellConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of xlsmapper Show documentation
Show all versions of xlsmapper Show documentation
XlsMapper is Java Library for mapping Excel sheets to POJO.
package com.gh.mygreen.xlsmapper.cellconvert.converter;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
/**
* byte/Byte型を処理するConverter.
*
* @version 0.5
* @author T.TSUCHIE
*
*/
public class ByteCellConverter extends AbstractNumberCellConverter {
@Override
protected Byte convertNumber(double value, final MathContext context) {
// 少数以下を四捨五入
BigDecimal decimal = new BigDecimal(value, context);
decimal = decimal.setScale(0, RoundingMode.HALF_UP);
return decimal.byteValueExact();
}
@Override
protected Byte convertNumber(final Number value, final MathContext context) {
return value.byteValue();
}
@Override
protected Byte convertNumber(final BigDecimal value) {
// 少数以下を四捨五入
BigDecimal decimal = value.setScale(0, RoundingMode.HALF_UP);
return decimal.byteValueExact();
}
@Override
protected Byte getZeroValue() {
return 0;
}
@Override
protected double getMaxValue() {
return Byte.MAX_VALUE;
}
@Override
protected double getMinValue() {
return Byte.MIN_VALUE;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy