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