View Javadoc
1   package com.github.mygreen.supercsv.cellprocessor.conversion;
2   
3   import java.util.Optional;
4   
5   import org.supercsv.cellprocessor.ift.CellProcessor;
6   import org.supercsv.cellprocessor.ift.StringCellProcessor;
7   
8   import com.github.mygreen.supercsv.annotation.conversion.CsvTrim;
9   import com.github.mygreen.supercsv.builder.Configuration;
10  import com.github.mygreen.supercsv.builder.FieldAccessor;
11  import com.github.mygreen.supercsv.cellprocessor.ConversionProcessorFactory;
12  import com.github.mygreen.supercsv.cellprocessor.format.TextFormatter;
13  
14  
15  /**
16   * アノテーション{@link CsvTrim}をハンドリングして、{@link Trim}を作成する。
17   *
18   * @since 2.0
19   * @author T.TSUCHIE
20   *
21   */
22  public class TrimFactory implements ConversionProcessorFactory<CsvTrim> {
23      
24      @Override
25      public Optional<CellProcessor> create(final CsvTrim anno, final Optional<CellProcessor> next,
26              final FieldAccessor field, final TextFormatter<?> formatter, final Configuration config) {
27          
28          final Trimr/conversion/Trim.html#Trim">Trim processor = next.map(n -> new Trim((StringCellProcessor)n))
29                  .orElseGet(() -> new Trim());
30          
31          return Optional.of(processor);
32      }
33  }