package com.zjrs.appcomm.template.excel.builder;

import com.zjrs.appcomm.template.excel.mapper.*;
import org.apache.poi.ss.usermodel.Sheet;

import java.util.Map;

public class ImportDefinition<D, L> {
	
	public static <D, L> ImportBuilder<D, L> builder(Class<D> discreteClass, Class<L> listClass) {
		return new ImportBuilder<>(discreteClass, listClass);
	}
	
	public ImportDefinition(Class<D> discreteClass, Class<L> listClass) {
		setDiscreteClass(discreteClass);
		setListClass(listClass);
	}
	
	private Class<D> discreteClass;
	public Class<D> getDiscreteClass() { return discreteClass; }
	public void setDiscreteClass(Class<D> discreteClass) { this.discreteClass = discreteClass; }
	
	private Class<L> listClass;
	public Class<L> getListClass() { return listClass; }
	public void setListClass(Class<L> listClass) { this.listClass = listClass; }

	/* Excel中Sheet */
	private Sheet sheet;
	public Sheet getSheet() { return sheet; }
	public void setSheet(Sheet sheet) { this.sheet = sheet; }
	
	/* 离散数据坐标 */
	private Map<String, SheetCoordinate> discreteFieldCoordinates;
	public Map<String, SheetCoordinate> getDiscreteFieldCoordinates() { return discreteFieldCoordinates; }
	public void setDiscreteFieldCoordinates(Map<String, SheetCoordinate> discreteFieldCoordinates) { this.discreteFieldCoordinates = discreteFieldCoordinates; }
	
	/* 处理离散数据的Mapper */
	private DiscreteMapper<D> discreteMapper;
	public DiscreteMapper<D> getDiscreteMapper() { return discreteMapper; }
	public void setDiscreteMapper(DiscreteMapper<D> discreteMapper) { this.discreteMapper = discreteMapper; }
	
	/* 导入数据的表头所在行下标（比如第一行就是表头，则传入0） */
	private int headerRowIndex;
	public int getHeaderRowIndex() { return headerRowIndex; }
	public void setHeaderRowIndex(int headerRowIndex) { this.headerRowIndex = headerRowIndex; }
	
	/* 导入数据的表头一共有几行（比如只有一行表头，则传入1，若是两行构成的多行表头，则传入2） */
	private int headerRowCount;
	public int getHeaderRowCount() { return headerRowCount; }
	public void setHeaderRowCount(int headerRowCount) { this.headerRowCount = headerRowCount; }
	
	/* 定义表头转换用的映射（主要针对动态表头而使用，对于静态表头可以直接传入固定值）（一般静态表头可使用StaticHeaderMapper、一般动态表头可使用DynamicHeaderMapper） */
	private HeaderMapper headerMapper;
	public HeaderMapper getHeaderMapper() { return headerMapper; }
	public void setHeaderMapper(HeaderMapper headerMapper) { this.headerMapper = headerMapper; }
	
	/* 是否进行合并单元格修正 */
	private boolean calculateMergedCell;
	public boolean isCalculateMergedCell() { return calculateMergedCell; }
	public void setCalculateMergedCell(boolean calculateMergedCell) { this.calculateMergedCell = calculateMergedCell; }

	/* 需要导入的数据所在行的起始下标（比如第二行就是数据，则传入1） */
	private int dataRowIndex;
	public int getDataRowIndex() { return dataRowIndex; }
	public void setDataRowIndex(int dataRowIndex) { this.dataRowIndex = dataRowIndex; }
	
	/* 行数据过滤器 */
	private RowJudge listFilter;
	public RowJudge getListFilter() { return listFilter; }
	public void setListFilter(RowJudge listFilter) { this.listFilter = listFilter; }
	
	/* 行数据终止器 */
	private RowJudge listfinishedJudge;
	public RowJudge getListfinishedJudge() { return listfinishedJudge; }
	public void setListfinishedJudge(RowJudge listfinishedJudge) { this.listfinishedJudge = listfinishedJudge; }
	
	/* 处理每行数据的Mapper */
	private RowMapper<L> rowMapper;
	public RowMapper<L> getRowMapper() { return rowMapper; }
	public void setRowMapper(RowMapper<L> rowMapper) { this.rowMapper = rowMapper; }
	
}
