View Javadoc
1   /*
2    * Copyright 2013 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package com.orangesignal.csv.manager;
18  
19  import java.util.List;
20  
21  import com.orangesignal.csv.CsvConfig;
22  
23  /**
24   * Java プログラム要素のリストと区切り文字形式データの統合アクセスインタフェースの実装クラスを提供します。
25   * 
26   * @author Koji Sugisawa
27   */
28  public class CsvBeanManager implements CsvManager {
29  
30  	/**
31  	 * 区切り文字形式情報を保持します。
32  	 */
33  	private CsvConfig csvConfig;
34  
35  	/**
36  	 * デフォルトコンストラクタです。
37  	 */
38  	public CsvBeanManager() {
39  		this(new CsvConfig());
40  	}
41  
42  	/**
43  	 * コンストラクタです。
44  	 * 
45  	 * @param cfg 区切り文字形式情報
46  	 * @throws IllegalArgumentException {@code cfg} が {@code null} の場合
47  	 */
48  	public CsvBeanManager(final CsvConfig cfg) {
49  		config(cfg);
50  	}
51  
52  	@Override
53  	public CsvBeanManager config(final CsvConfig cfg) {
54  		if (cfg == null) {
55  			throw new IllegalArgumentException("CsvConfig must not be null");
56  		}
57  		this.csvConfig = cfg;
58  		return this;
59  	}
60  
61  	@Override
62  	public <T> CsvBeanLoader<T> load(final Class<T> beanClass) {
63  		return new CsvBeanLoader<T>(csvConfig, beanClass);
64  	}
65  
66  	@Override
67  	public <T> CsvBeanSaver<T> save(final List<T> beans, final Class<T> beanClass) {
68  		return new CsvBeanSaver<T>(csvConfig, beans, beanClass);
69  	}
70  
71  }