Skip to content

Commit

Permalink
fix: when property mapping is not configured, value-to-key mapping is…
Browse files Browse the repository at this point in the history
… used by default (GitHub #190)
  • Loading branch information
Createsequence committed Jan 17, 2024
1 parent 184e213 commit 8042e04
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import cn.crane4j.core.parser.BeanOperationParser;
import cn.crane4j.core.parser.BeanOperations;
import cn.crane4j.core.parser.PropertyMapping;
import cn.crane4j.core.parser.SimplePropertyMapping;
import cn.crane4j.core.parser.handler.strategy.OverwriteNotNullMappingStrategy;
import cn.crane4j.core.parser.handler.strategy.PropertyMappingStrategy;
import cn.crane4j.core.parser.handler.strategy.PropertyMappingStrategyManager;
Expand All @@ -34,6 +35,7 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Field;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
Expand Down Expand Up @@ -280,7 +282,9 @@ protected Set<PropertyMapping> parsePropertyMappings(
if (CollectionUtils.isNotEmpty(templateMappings)) {
propertyMappings.addAll(templateMappings);
}
return propertyMappings;
// fix https://github.com/opengoofy/crane4j/issues/190
return propertyMappings.isEmpty() ?
Collections.singleton(new SimplePropertyMapping("", key)) : propertyMappings;
}

/**
Expand Down

0 comments on commit 8042e04

Please sign in to comment.