mapping exclusions
This commit is contained in:
@@ -50,4 +50,9 @@ public interface MappingConfiguration {
|
||||
*/
|
||||
MappingConfiguration setGenericConverter(GenericConverter converter);
|
||||
|
||||
/**
|
||||
* Configures that this mapping should be excluded (ignored and not executed).
|
||||
*/
|
||||
void setExclude();
|
||||
|
||||
}
|
||||
@@ -122,7 +122,7 @@ public class SpelMapper implements Mapper<Object, Object> {
|
||||
* @param nestedMapper the nested mapper
|
||||
*/
|
||||
public void addNestedMapper(Mapper<?, ?> nestedMapper) {
|
||||
Class[] typeInfo = getRequiredTypeInfo(nestedMapper);
|
||||
Class<?>[] typeInfo = getRequiredTypeInfo(nestedMapper);
|
||||
addNestedMapper(typeInfo[0], typeInfo[1], nestedMapper);
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ public class SpelMapper implements Mapper<Object, Object> {
|
||||
* @param targetType the target nested property type
|
||||
* @param nestedMapper the nested mapper
|
||||
*/
|
||||
public void addNestedMapper(Class sourceType, Class targetType, Mapper<?, ?> nestedMapper) {
|
||||
public void addNestedMapper(Class<?> sourceType, Class<?> targetType, Mapper<?, ?> nestedMapper) {
|
||||
this.conversionService.addGenericConverter(sourceType, targetType, new MapperConverter(nestedMapper));
|
||||
}
|
||||
|
||||
|
||||
@@ -38,18 +38,14 @@ class SpelMapping implements MappingConfiguration {
|
||||
|
||||
private GenericConverter converter;
|
||||
|
||||
private boolean exclude;
|
||||
|
||||
public SpelMapping(Expression source, Expression target) {
|
||||
this.source = source;
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
public String getSourceExpressionString() {
|
||||
return this.source.getExpressionString();
|
||||
}
|
||||
|
||||
public String getTargetExpressionString() {
|
||||
return this.target.getExpressionString();
|
||||
}
|
||||
// implementing MappingConfiguration
|
||||
|
||||
public MappingConfiguration setConverter(Converter<?, ?> converter) {
|
||||
return setGenericConverter(new ConverterGenericConverter(converter));
|
||||
@@ -64,8 +60,25 @@ class SpelMapping implements MappingConfiguration {
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setExclude() {
|
||||
this.exclude = true;
|
||||
}
|
||||
|
||||
// public methods
|
||||
|
||||
public String getSourceExpressionString() {
|
||||
return this.source.getExpressionString();
|
||||
}
|
||||
|
||||
public String getTargetExpressionString() {
|
||||
return this.target.getExpressionString();
|
||||
}
|
||||
|
||||
public void map(EvaluationContext sourceContext, EvaluationContext targetContext,
|
||||
Collection<MappingFailure> failures) {
|
||||
if (exclude) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Object value = this.source.getValue(sourceContext);
|
||||
if (this.converter != null) {
|
||||
|
||||
Reference in New Issue
Block a user