diff --git a/processor/src/main/java/org/mapstruct/ap/internal/model/BeanMappingMethod.java b/processor/src/main/java/org/mapstruct/ap/internal/model/BeanMappingMethod.java index 324df63cc..2dba4637f 100644 --- a/processor/src/main/java/org/mapstruct/ap/internal/model/BeanMappingMethod.java +++ b/processor/src/main/java/org/mapstruct/ap/internal/model/BeanMappingMethod.java @@ -98,6 +98,7 @@ public class BeanMappingMethod extends NormalTypeMappingMethod { private Map unprocessedConstructorProperties; private Map unprocessedTargetProperties; private Map unprocessedSourceProperties; + private Set missingIgnoredSourceProperties; private Set targetProperties; private final List propertyMappings = new ArrayList<>(); private final Set unprocessedSourceParameters = new HashSet<>(); @@ -248,9 +249,12 @@ public class BeanMappingMethod extends NormalTypeMappingMethod { } // get bean mapping (when specified as annotation ) + this.missingIgnoredSourceProperties = new HashSet<>(); if ( beanMapping != null ) { for ( String ignoreUnmapped : beanMapping.getIgnoreUnmappedSourceProperties() ) { - unprocessedSourceProperties.remove( ignoreUnmapped ); + if ( unprocessedSourceProperties.remove( ignoreUnmapped ) == null ) { + missingIgnoredSourceProperties.add( ignoreUnmapped ); + } } } @@ -283,6 +287,7 @@ public class BeanMappingMethod extends NormalTypeMappingMethod { // report errors on unmapped properties reportErrorForUnmappedTargetPropertiesIfRequired(); reportErrorForUnmappedSourcePropertiesIfRequired(); + reportErrorForMissingIgnoredSourceProperties(); // mapNullToDefault boolean mapNullToDefault = method.getOptions() @@ -1511,6 +1516,24 @@ public class BeanMappingMethod extends NormalTypeMappingMethod { ); } } + + private void reportErrorForMissingIgnoredSourceProperties() { + if ( !missingIgnoredSourceProperties.isEmpty() ) { + Object[] args = new Object[] { + MessageFormat.format( + "{0,choice,1#property|1