View Javadoc
1   package com.github.mygreen.supercsv.io;
2   
3   import org.supercsv.cellprocessor.ift.CellProcessor;
4   
5   import com.github.mygreen.supercsv.builder.BeanMapping;
6   
7   
8   /**
9    * Beanのマッピング情報のキャッシュ。
10   * <p>レコードの実行ごとに、</p>
11   *
12   * @version 2.0
13   * @author T.TSUCHIE
14   *
15   */
16  public class BeanMappingCache<T> {
17      
18      private final BeanMapping<T> beanMapping;
19      
20      private String[] header;
21      
22      private String[] nameMapping;
23      
24      private CellProcessor[] cellProcessorsForReading;
25      
26      private CellProcessor[] cellProcessorsForWriting;
27      
28      private BeanMappingCache(final BeanMapping<T> beanMapping) {
29          this.beanMapping = beanMapping;
30      }
31      
32      public static <T> BeanMappingCache<T> create(final BeanMapping<T> beanMapping) {
33          
34          final BeanMappingCache<T> cache = new BeanMappingCache<>(beanMapping);
35          
36          cache.header = beanMapping.getHeader();
37          cache.nameMapping = beanMapping.getNameMapping();
38          cache.cellProcessorsForReading = beanMapping.getCellProcessorsForReading();
39          cache.cellProcessorsForWriting = beanMapping.getCellProcessorsForWriting();
40          
41          return cache;
42      }
43      
44      /**
45       * キャッシュ元のデータを取得する。
46       * @return キャッシュ元となったマッピング情報。
47       */
48      public BeanMapping<T> getOriginal() {
49          return beanMapping;
50      }
51      
52      
53      public String[] getHeader() {
54          return header;
55      }
56      
57      public String[] getNameMapping() {
58          return nameMapping;
59      }
60      
61      public CellProcessor[] getCellProcessorsForReading() {
62          return cellProcessorsForReading;
63      }
64      
65      public CellProcessor[] getCellProcessorsForWriting() {
66          return cellProcessorsForWriting;
67      }
68      
69  }