diff --git a/src/main/java/com/alibaba/excel/metadata/property/ExcelHeadProperty.java b/src/main/java/com/alibaba/excel/metadata/property/ExcelHeadProperty.java index c3454755..2565d563 100644 --- a/src/main/java/com/alibaba/excel/metadata/property/ExcelHeadProperty.java +++ b/src/main/java/com/alibaba/excel/metadata/property/ExcelHeadProperty.java @@ -1,6 +1,7 @@ package com.alibaba.excel.metadata.property; import java.lang.reflect.Field; +import java.util.AbstractMap; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -124,16 +125,16 @@ public class ExcelHeadProperty { Map customFieldMap = new TreeMap(); ClassUtils.declaredFields(headClazz, defaultFieldList, customFieldMap, ignoreMap, convertAllField); - List> exportFieldBoolPairsList = new ArrayList>(); + List> exportFieldBoolPairsList = new ArrayList>(); int index = 0; while (customFieldMap.containsKey(index)) { Field field = customFieldMap.get(index); - Pair fieldBooleanPair = new Pair(field, Boolean.TRUE); + Map.Entry fieldBooleanPair = new AbstractMap.SimpleEntry(field, Boolean.TRUE); exportFieldBoolPairsList.add(fieldBooleanPair); index++; } for (Field field : defaultFieldList) { - Pair fieldBoolPair = new Pair(field, Boolean.FALSE); + Map.Entry fieldBoolPair = new AbstractMap.SimpleEntry(field, Boolean.FALSE); exportFieldBoolPairsList.add(fieldBoolPair); } @@ -155,13 +156,13 @@ public class ExcelHeadProperty { * @param exportFieldBoolPairList Keep all the fields and the flag(which indicate whether the field order is specified) * of the head class except the ignored. It will be modified after this function is called. */ - private void sortExportColumnFields(Holder holder, List> exportFieldBoolPairList) { + private void sortExportColumnFields(Holder holder, List> exportFieldBoolPairList) { if (holder instanceof AbstractWriteHolder) { Collection includeColumnFieldNames = ((AbstractWriteHolder) holder).getIncludeColumnFieldNames(); if (includeColumnFieldNames != null) { - Map> exportFieldMap = new TreeMap>(); + Map> exportFieldMap = new TreeMap>(); List includeColumnFieldNameList = new ArrayList(includeColumnFieldNames); - for (Pair fieldBoolPair : exportFieldBoolPairList) { + for (Map.Entry fieldBoolPair : exportFieldBoolPairList) { if (includeColumnFieldNameList.contains(fieldBoolPair.getKey().getName())) { exportFieldMap.put(fieldBoolPair.getKey().getName(), fieldBoolPair); } @@ -175,7 +176,7 @@ public class ExcelHeadProperty { Collection includeColumnIndexes = ((AbstractWriteHolder) holder).getIncludeColumnIndexes(); if (includeColumnIndexes != null) { - List> tempFieldsList = new ArrayList>(); + List> tempFieldsList = new ArrayList>(); for (Integer includeColumnIndex : includeColumnIndexes) { tempFieldsList.add(exportFieldBoolPairList.get(includeColumnIndex)); } @@ -185,7 +186,7 @@ public class ExcelHeadProperty { } int index = 0; - for (Pair fieldBoolPair : exportFieldBoolPairList) { + for (Map.Entry fieldBoolPair : exportFieldBoolPairList) { if (((AbstractWriteHolder) holder).ignore(fieldBoolPair.getKey().getName(), index)) { exportFieldBoolPairList.remove(fieldBoolPair); } @@ -201,9 +202,9 @@ public class ExcelHeadProperty { * @param exportFieldBoolPairList Keep the fields which will be exported to excel and the flag which indicate whether * the field order in excel is specified. */ - private void initColumnProperties(Holder holder, List> exportFieldBoolPairList) { + private void initColumnProperties(Holder holder, List> exportFieldBoolPairList) { int index = 0; - for (Pair fieldBoolPair : exportFieldBoolPairList) { + for (Map.Entry fieldBoolPair : exportFieldBoolPairList) { initOneColumnProperty(holder, index, fieldBoolPair.getKey(), fieldBoolPair.getValue()); index++; }