Browse Source

reverse import

pull/3186/head
gongxuanzhang 2 years ago
parent
commit
6bf3b1ec36
  1. 19
      easyexcel-core/src/main/java/com/alibaba/excel/util/ClassUtils.java

19
easyexcel-core/src/main/java/com/alibaba/excel/util/ClassUtils.java

@ -49,7 +49,7 @@ import org.springframework.cglib.beans.BeanMap;
* The ASF licenses this file to You under the Apache License, Version 2.0 * The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with * (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 * the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* <p> *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -102,8 +102,7 @@ public class ClassUtils {
* @return * @return
*/ */
public static ExcelContentProperty declaredExcelContentProperty(Map<?, ?> dataMap, Class<?> headClazz, public static ExcelContentProperty declaredExcelContentProperty(Map<?, ?> dataMap, Class<?> headClazz,
String fieldName, String fieldName, ConfigurationHolder configurationHolder) {
ConfigurationHolder configurationHolder) {
Class<?> clazz = null; Class<?> clazz = null;
if (dataMap instanceof BeanMap) { if (dataMap instanceof BeanMap) {
Object bean = ((BeanMap)dataMap).getBean(); Object bean = ((BeanMap)dataMap).getBean();
@ -138,8 +137,7 @@ public class ClassUtils {
} }
private static ExcelContentProperty doGetExcelContentProperty(Class<?> clazz, Class<?> headClass, private static ExcelContentProperty doGetExcelContentProperty(Class<?> clazz, Class<?> headClass,
String fieldName, String fieldName, ConfigurationHolder configurationHolder) {
ConfigurationHolder configurationHolder) {
ExcelContentProperty excelContentProperty = Optional.ofNullable( ExcelContentProperty excelContentProperty = Optional.ofNullable(
declaredFieldContentMap(clazz, configurationHolder)) declaredFieldContentMap(clazz, configurationHolder))
.map(map -> map.get(fieldName)) .map(map -> map.get(fieldName))
@ -335,7 +333,7 @@ public class ClassUtils {
return fieldCache; return fieldCache;
} }
// ignore filed // ignore filed
Map<Integer, FieldWrapper> tempSortedFieldMap = MapUtils.newHashMap(); Map<Integer, FieldWrapper> tempSortedFieldMapp = MapUtils.newHashMap();
int index = 0; int index = 0;
for (Map.Entry<Integer, FieldWrapper> entry : sortedFieldMap.entrySet()) { for (Map.Entry<Integer, FieldWrapper> entry : sortedFieldMap.entrySet()) {
Integer key = entry.getKey(); Integer key = entry.getKey();
@ -348,18 +346,18 @@ public class ClassUtils {
} else { } else {
// Mandatory sorted fields // Mandatory sorted fields
if (indexFieldMap.containsKey(key)) { if (indexFieldMap.containsKey(key)) {
tempSortedFieldMap.put(key, field); tempSortedFieldMapp.put(key, field);
} else { } else {
// Need to reorder automatically // Need to reorder automatically
// Check whether the current key is already in use // Check whether the current key is already in use
while (tempSortedFieldMap.containsKey(index)) { while (tempSortedFieldMapp.containsKey(index)) {
index++; index++;
} }
tempSortedFieldMap.put(index++, field); tempSortedFieldMapp.put(index++, field);
} }
} }
} }
fieldCache.setSortedFieldMap(tempSortedFieldMap); fieldCache.setSortedFieldMap(tempSortedFieldMapp);
// resort field // resort field
resortField(writeHolder, fieldCache); resortField(writeHolder, fieldCache);
@ -559,3 +557,4 @@ public class ClassUtils {
CONTENT_THREAD_LOCAL.remove(); CONTENT_THREAD_LOCAL.remove();
} }
} }

Loading…
Cancel
Save