com.github.rrsunhome.excelsql.config.SqlFormatConfig Maven / Gradle / Ivy
package com.github.rrsunhome.excelsql.config;
import com.github.rrsunhome.excelsql.format.Formatter;
import com.github.rrsunhome.excelsql.format.MessageFormatter;
import lombok.Getter;
import org.apache.poi.ss.formula.functions.T;
import java.util.HashMap;
import java.util.Map;
/**
* @author : wangqijia
* create at: 2021/11/7 下午1:09
*/
@Getter
public class SqlFormatConfig {
private String sql;
private Map> parameterValueMap = new HashMap<>(16);
private Formatter formatter;
public SqlFormatConfig(String sql, Formatter sqlFormatter) {
this.sql = sql;
this.formatter = sqlFormatter;
}
public SqlFormatConfig(String sql) {
this(sql, new MessageFormatter());
}
public SqlFormatConfig setString(int parameterIndex, int cellIndex) {
set(parameterIndex, cellIndex, String.class);
return this;
}
public SqlFormatConfig setInt(int parameterIndex, int cellIndex) {
set(parameterIndex, cellIndex, Integer.class);
return this;
}
private void set(int parameterIndex, int cellIndex, Class> cellType) {
parameterValueMap.put(parameterIndex, new SqlParameterIndexValue<>(cellIndex, cellType));
}
}