package egovframework.util.excel;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class ExcelSheetDataGroup { // (2)
	private final List<ExcelSheetData> dataList;

	private ExcelSheetDataGroup(List<ExcelSheetData> data) {
		validateEmpty(data);
		this.dataList = new ArrayList<>(data);
	}

	public List<ExcelSheetData> getExcelSheetData() {
		return Collections.unmodifiableList(dataList);
	}

	public static ExcelSheetDataGroup of(ExcelSheetData... data) {
		List<ExcelSheetData> list;
		if (data == null) {
			list = Collections.emptyList();
		} else {
			list = Arrays.asList(data);
		}
		return new ExcelSheetDataGroup(list);
	}

	private void validateEmpty(List<ExcelSheetData> data) {
		if (data.isEmpty()) {
			throw new IllegalArgumentException("lists must not be empty");
		}
	}
}
