FloatCellConverterFactory.java

  1. package com.gh.mygreen.xlsmapper.cellconverter.impl;

  2. import java.math.BigDecimal;

  3. import com.gh.mygreen.xlsmapper.Configuration;
  4. import com.gh.mygreen.xlsmapper.cellconverter.CellConverter;
  5. import com.gh.mygreen.xlsmapper.fieldaccessor.FieldAccessor;

  6. /**
  7.  * {@link Float}型を処理する{@link CellConverter}を作成するクラス。
  8.  *
  9.  * @since 2.0
  10.  * @author T.TSUCHIE
  11.  *
  12.  */
  13. public class FloatCellConverterFactory extends AbstractNumberCellConverterFactory<Float> {
  14.    
  15.     @Override
  16.     public FloatCellConverter create(final FieldAccessor field, final Configuration config) {
  17.        
  18.         final FloatCellConverter cellConverter = new FloatCellConverter(field, config, this);
  19.         setupCellConverter(cellConverter, field, config);
  20.        
  21.         return cellConverter;
  22.        
  23.     }
  24.    
  25.     @Override
  26.     protected Float convertTypeValue(final BigDecimal value) throws NumberFormatException, ArithmeticException {
  27.         return value.floatValue();
  28.     }
  29.    
  30.     public class FloatCellConverter extends AbstractNumberCellConverter<Float> {
  31.        
  32.         private final FloatCellConverterFactory convererFactory;
  33.        
  34.         private FloatCellConverter(final FieldAccessor field, final Configuration config,
  35.                 final FloatCellConverterFactory convererFactory) {
  36.             super(field, config);
  37.             this.convererFactory = convererFactory;
  38.         }
  39.        
  40.         @Override
  41.         protected Float convertTypeValue(final BigDecimal value) {
  42.             return convererFactory.convertTypeValue(value);
  43.         }
  44.        
  45.     }
  46.    
  47. }