Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
liaochong committed Nov 14, 2024
1 parent 430d6b8 commit 90fb7a8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<groupId>com.github.liaochong</groupId>
<artifactId>myexcel</artifactId>
<version>4.5.5</version>
<version>4.5.6</version>
<packaging>jar</packaging>

<name>myexcel</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package com.github.liaochong.myexcel.core.converter.writer;

import com.github.liaochong.myexcel.core.ExcelColumnMapping;
import com.github.liaochong.myexcel.core.cache.WeakCache;
import com.github.liaochong.myexcel.core.container.Pair;
import com.github.liaochong.myexcel.core.converter.ConvertContext;
import com.github.liaochong.myexcel.core.converter.WriteConverter;
Expand All @@ -30,8 +29,6 @@
*/
public class MappingWriteConverter implements WriteConverter {

private final WeakCache<String, Pair<Class, Object>> mappingCache = new WeakCache<>();

@Override
public boolean support(Field field, Class<?> fieldType, Object fieldVal, ConvertContext convertContext) {
ExcelColumnMapping mapping = convertContext.excelColumnMappingMap.get(field);
Expand All @@ -41,18 +38,11 @@ public boolean support(Field field, Class<?> fieldType, Object fieldVal, Convert
@Override
public Pair<Class, Object> convert(Field field, Class<?> fieldType, Object fieldVal, ConvertContext convertContext) {
ExcelColumnMapping excelColumnMapping = convertContext.excelColumnMappingMap.get(field);
String cacheKey = excelColumnMapping.mapping + "->" + fieldVal;
Pair<Class, Object> mapping = mappingCache.get(cacheKey);
if (mapping != null) {
return mapping;
}
Properties properties = PropertyUtil.getProperties(excelColumnMapping);
String property = properties.getProperty(fieldVal.toString());
if (property == null) {
return Pair.of(fieldType, fieldVal);
}
Pair<Class, Object> result = Pair.of(String.class, property);
mappingCache.cache(cacheKey, result);
return result;
return Pair.of(String.class, property);
}
}

0 comments on commit 90fb7a8

Please sign in to comment.