22
33import org .slf4j .Logger ;
44import org .slf4j .LoggerFactory ;
5+ import seven .callBack .ConvertInterface ;
56
67import java .util .Arrays ;
8+ import java .util .HashMap ;
9+ import java .util .Map ;
710import java .util .Objects ;
811
912public class Config {
10- private static final Logger logger = LoggerFactory .getLogger (Config .class );
13+ private static final Logger logger = LoggerFactory .getLogger (Config .class );
1114
1215 private Integer titleRow = 0 ;
1316 private Integer contentRowStart = 1 ;
@@ -19,25 +22,28 @@ public class Config {
1922 private String [] require = null ;
2023 private Integer startSheet = 0 ;
2124 private Integer endSheet = null ;
22- private Integer sheetIndex = -1 ;
25+ private Integer sheetIndex = -1 ;
2326 private String sheetName = null ;
27+ private Map <String , Class <? extends ConvertInterface >> convertMap = new HashMap <>();
28+ private Map <String , ConvertInterface > convertMapImpl = new HashMap <>();
2429
2530 public Config () {
2631 }
2732
28- private boolean args (Object ... params ){
33+ private boolean args (Object ... params ) {
2934 return Arrays .stream (params ).anyMatch (Objects ::isNull );
3035 }
3136
32- public void check () throws RuntimeException {
33- if (args (titleRow ,contentRowStart )){
34- logger .error ("config[titleRow,contentRowStart] is null, the config {}" ,this );
37+ public void check () throws RuntimeException {
38+ if (args (titleRow , contentRowStart )) {
39+ logger .error ("config[titleRow,contentRowStart] is null, the config {}" , this );
3540 throw new RuntimeException ("onfig[titleRow,contentRowStart] is null" );
36- }else {
37- logger .info ("config[titleRow,contentRowStart] is null, the config {}" ,this );
41+ } else {
42+ logger .info ("config[titleRow,contentRowStart] is null, the config {}" , this );
3843 }
3944
4045 }
46+
4147 @ Deprecated
4248 public String [] getRequire () {
4349 return require ;
@@ -79,6 +85,23 @@ public Config setErrorLog(Boolean errorLog) {
7985 return this ;
8086 }
8187
88+ @ Deprecated
89+ public Config withConvert (String name , Class <? extends ConvertInterface > clazz ) {
90+ this .convertMap .put (name , clazz );
91+ return this ;
92+ }
93+
94+ /**
95+ * @param name
96+ * @param convert
97+ * @return
98+ */
99+ @ Deprecated
100+ public Config withConvert (String name , ConvertInterface convert ) {
101+ this .convertMapImpl .put (name , convert );
102+ return this ;
103+ }
104+
82105 public Integer getSheetIndex () {
83106 return sheetIndex ;
84107 }
@@ -138,6 +161,14 @@ public Integer getContentRowEnd() {
138161 return contentRowEnd ;
139162 }
140163
164+ public Map <String , Class <? extends ConvertInterface >> getConvertMap () {
165+ return convertMap ;
166+ }
167+
168+ public Map <String , ConvertInterface > getConvertMapImpl () {
169+ return convertMapImpl ;
170+ }
171+
141172 /**
142173 * 内容结束行号
143174 */
@@ -175,17 +206,8 @@ public Config endSheet(Integer endSheet) {
175206
176207 @ Override
177208 public String toString () {
178- return "Config{" +
179- "titleRow=" + titleRow +
180- ", contentRowStart=" + contentRowStart +
181- ", contentRowEnd=" + contentRowEnd +
182- ", isLoopSheet=" + isLoopSheet +
183- ", errorLog=" + errorLog +
184- ", vocSize=" + vocSize +
185- ", require=" + Arrays .toString (require ) +
186- ", startSheet=" + startSheet +
187- ", endSheet=" + endSheet +
188- '}' ;
209+ return "Config{" + "titleRow=" + titleRow + ", contentRowStart=" + contentRowStart + ", contentRowEnd=" + contentRowEnd + ", isLoopSheet=" + isLoopSheet + ", errorLog=" + errorLog + ", vocSize=" + vocSize + ", require=" + Arrays
210+ .toString (require ) + ", startSheet=" + startSheet + ", endSheet=" + endSheet + '}' ;
189211 }
190212
191213
0 commit comments