#618 Improve detection of unspecified annotation attributes and remove all "DEFAULT"/"default" values from annotations and enums that were previously only created to detect if a value was assigned or not.

This commit is contained in:
Andreas Gudian 2015-08-13 20:38:43 +02:00
parent 44037172fc
commit a85168f298
18 changed files with 75 additions and 153 deletions

View File

@ -61,5 +61,5 @@ public @interface BeanMapping {
* *
* @return The strategy to be applied when {@code null} is passed as source value to the methods of this mapping. * @return The strategy to be applied when {@code null} is passed as source value to the methods of this mapping.
*/ */
NullValueMappingStrategy nullValueMappingStrategy() default NullValueMappingStrategy.DEFAULT; NullValueMappingStrategy nullValueMappingStrategy() default NullValueMappingStrategy.RETURN_NULL;
} }

View File

@ -51,12 +51,5 @@ public enum CollectionMappingStrategy {
* Identical to {@link #SETTER_PREFERRED}, only that adder methods will be preferred over setter methods, if both * Identical to {@link #SETTER_PREFERRED}, only that adder methods will be preferred over setter methods, if both
* are present for a given collection-typed property. * are present for a given collection-typed property.
*/ */
ADDER_PREFERRED, ADDER_PREFERRED;
/**
* If given via {@link Mapper#collectionMappingStrategy()}, causes the setting specified via
* {@link MapperConfig#collectionMappingStrategy()} to be applied, if present. Otherwise causes
* {@link #ACCESSOR_ONLY} to be applied.
*/
DEFAULT;
} }

View File

@ -73,5 +73,5 @@ public @interface IterableMapping {
* *
* @return The strategy to be applied when {@code null} is passed as source value to the methods of this mapping. * @return The strategy to be applied when {@code null} is passed as source value to the methods of this mapping.
*/ */
NullValueMappingStrategy nullValueMappingStrategy() default NullValueMappingStrategy.DEFAULT; NullValueMappingStrategy nullValueMappingStrategy() default NullValueMappingStrategy.RETURN_NULL;
} }

View File

@ -104,5 +104,5 @@ public @interface MapMapping {
* *
* @return The strategy to be applied when {@code null} is passed as source value to the methods of this mapping. * @return The strategy to be applied when {@code null} is passed as source value to the methods of this mapping.
*/ */
NullValueMappingStrategy nullValueMappingStrategy() default NullValueMappingStrategy.DEFAULT; NullValueMappingStrategy nullValueMappingStrategy() default NullValueMappingStrategy.RETURN_NULL;
} }

View File

@ -59,7 +59,7 @@ public @interface Mapper {
* *
* @return The reporting policy for unmapped target properties. * @return The reporting policy for unmapped target properties.
*/ */
ReportingPolicy unmappedTargetPolicy() default ReportingPolicy.DEFAULT; ReportingPolicy unmappedTargetPolicy() default ReportingPolicy.WARN;
/** /**
* Specifies the component model to which the generated mapper should * Specifies the component model to which the generated mapper should
@ -103,7 +103,7 @@ public @interface Mapper {
* *
* @return The strategy applied when propagating the value of collection-typed properties. * @return The strategy applied when propagating the value of collection-typed properties.
*/ */
CollectionMappingStrategy collectionMappingStrategy() default CollectionMappingStrategy.DEFAULT; CollectionMappingStrategy collectionMappingStrategy() default CollectionMappingStrategy.ACCESSOR_ONLY;
/** /**
* The strategy to be applied when {@code null} is passed as source value to the methods of this mapper. If no * The strategy to be applied when {@code null} is passed as source value to the methods of this mapper. If no
@ -112,7 +112,7 @@ public @interface Mapper {
* *
* @return The strategy to be applied when {@code null} is passed as source value to the methods of this mapper. * @return The strategy to be applied when {@code null} is passed as source value to the methods of this mapper.
*/ */
NullValueMappingStrategy nullValueMappingStrategy() default NullValueMappingStrategy.DEFAULT; NullValueMappingStrategy nullValueMappingStrategy() default NullValueMappingStrategy.RETURN_NULL;
/** /**
* The strategy to use for applying method-level configuration annotations of prototype methods in the interface * The strategy to use for applying method-level configuration annotations of prototype methods in the interface
@ -125,5 +125,5 @@ public @interface Mapper {
* @return The strategy to use for applying {@code @Mapping} configurations of prototype methods in the interface * @return The strategy to use for applying {@code @Mapping} configurations of prototype methods in the interface
* specified with {@link #config()}. * specified with {@link #config()}.
*/ */
MappingInheritanceStrategy mappingInheritanceStrategy() default MappingInheritanceStrategy.DEFAULT; MappingInheritanceStrategy mappingInheritanceStrategy() default MappingInheritanceStrategy.EXPLICIT;
} }

View File

@ -35,13 +35,5 @@ public enum MappingInheritanceStrategy {
* Inherit the method-level configuration annotations automatically if source and target types of the prototype * Inherit the method-level configuration annotations automatically if source and target types of the prototype
* method are assignable from the types of a given mapping method. * method are assignable from the types of a given mapping method.
*/ */
AUTO_INHERIT_FROM_CONFIG, AUTO_INHERIT_FROM_CONFIG;
/**
* When given via {@link Mapper#mappingInheritanceStrategy()}, the value specified via
* {@link MapperConfig#mappingInheritanceStrategy()} will be applied, if present.
* <p>
* When given via {@link MapperConfig#mappingInheritanceStrategy()}, the strategy {@link #EXPLICIT} will be applied.
*/
DEFAULT;
} }

View File

@ -43,16 +43,5 @@ public enum NullValueMappingStrategy {
* <li>For map mapping methods an empty map will be returned.</li> * <li>For map mapping methods an empty map will be returned.</li>
* </ul> * </ul>
*/ */
RETURN_DEFAULT, RETURN_DEFAULT;
/**
* When given via {@link Mapper#nullValueMappingStrategy()}, causes the setting specified via
* {@link MapperConfig#nullValueMappingStrategy()} to be applied, if present.
* <p>
* When given on specific mapping methods (e.g. via @ BeanMapping#nullValueMappingStrategy()}), causes the setting
* specified via {@link Mapper#nullValueMappingStrategy() ()} to be applied, if present.
* <p>
* Otherwise causes {@link #RETURN_NULL} to be applied.
*/
DEFAULT;
} }

View File

@ -42,15 +42,5 @@ public enum ReportingPolicy {
* A report with {@link Kind#ERROR} will be created for the given issue, * A report with {@link Kind#ERROR} will be created for the given issue,
* causing the compilation to fail. * causing the compilation to fail.
*/ */
ERROR, ERROR;
/**
* When given as value for {@link Mapper#unmappedTargetPolicy()}, the setting from the configuration source
* referenced via {@link Mapper#config()} will be applied.
* <p>
* Otherwise (no configuration source is referenced, or this value is given via
* {@link MapperConfig#unmappedTargetPolicy()}), a report with {@link Kind#WARNING} will be created for the given
* issue.
*/
DEFAULT;
} }

View File

@ -50,11 +50,13 @@ public class BeanMapping {
boolean resultTypeIsDefined = !TypeKind.VOID.equals( beanMapping.resultType().getKind() ); boolean resultTypeIsDefined = !TypeKind.VOID.equals( beanMapping.resultType().getKind() );
NullValueMappingStrategyPrism nullValueMappingStrategy NullValueMappingStrategyPrism nullValueMappingStrategy =
= NullValueMappingStrategyPrism.valueOf( beanMapping.nullValueMappingStrategy() ); null == beanMapping.values.nullValueMappingStrategy()
? null
: NullValueMappingStrategyPrism.valueOf( beanMapping.nullValueMappingStrategy() );
if ( !resultTypeIsDefined && beanMapping.qualifiedBy().isEmpty() if ( !resultTypeIsDefined && beanMapping.qualifiedBy().isEmpty()
&& ( nullValueMappingStrategy == NullValueMappingStrategyPrism.DEFAULT ) ) { && ( nullValueMappingStrategy == null ) ) {
messager.printMessage( method, Message.BEANMAPPING_NO_ELEMENTS ); messager.printMessage( method, Message.BEANMAPPING_NO_ELEMENTS );
} }

View File

@ -53,13 +53,15 @@ public class IterableMapping {
boolean elementTargetTypeIsDefined = !TypeKind.VOID.equals( iterableMapping.elementTargetType().getKind() ); boolean elementTargetTypeIsDefined = !TypeKind.VOID.equals( iterableMapping.elementTargetType().getKind() );
NullValueMappingStrategyPrism nullValueMappingStrategy NullValueMappingStrategyPrism nullValueMappingStrategy =
= NullValueMappingStrategyPrism.valueOf( iterableMapping.nullValueMappingStrategy() ); iterableMapping.values.nullValueMappingStrategy() == null
? null
: NullValueMappingStrategyPrism.valueOf( iterableMapping.nullValueMappingStrategy() );
if ( !elementTargetTypeIsDefined if ( !elementTargetTypeIsDefined
&& iterableMapping.dateFormat().isEmpty() && iterableMapping.dateFormat().isEmpty()
&& iterableMapping.qualifiedBy().isEmpty() && iterableMapping.qualifiedBy().isEmpty()
&& ( nullValueMappingStrategy == NullValueMappingStrategyPrism.DEFAULT ) ) { && ( nullValueMappingStrategy == null ) ) {
messager.printMessage( method, Message.ITERABLEMAPPING_NO_ELEMENTS ); messager.printMessage( method, Message.ITERABLEMAPPING_NO_ELEMENTS );
} }

View File

@ -52,8 +52,10 @@ public class MapMapping {
return null; return null;
} }
NullValueMappingStrategyPrism nullValueMappingStrategy NullValueMappingStrategyPrism nullValueMappingStrategy =
= NullValueMappingStrategyPrism.valueOf( mapMapping.nullValueMappingStrategy() ); mapMapping.values.nullValueMappingStrategy() == null
? null
: NullValueMappingStrategyPrism.valueOf( mapMapping.nullValueMappingStrategy() );
boolean keyTargetTypeIsDefined = !TypeKind.VOID.equals( mapMapping.keyTargetType().getKind() ); boolean keyTargetTypeIsDefined = !TypeKind.VOID.equals( mapMapping.keyTargetType().getKind() );
@ -64,7 +66,7 @@ public class MapMapping {
&& mapMapping.valueQualifiedBy().isEmpty() && mapMapping.valueQualifiedBy().isEmpty()
&& !keyTargetTypeIsDefined && !keyTargetTypeIsDefined
&& !valueTargetTypeIsDefined && !valueTargetTypeIsDefined
&& ( nullValueMappingStrategy == NullValueMappingStrategyPrism.DEFAULT ) ) { && ( nullValueMappingStrategy == null ) ) {
messager.printMessage( method, Message.MAPMAPPING_NO_ELEMENTS ); messager.printMessage( method, Message.MAPMAPPING_NO_ELEMENTS );
} }

View File

@ -18,12 +18,13 @@
*/ */
package org.mapstruct.ap.internal.model.source; package org.mapstruct.ap.internal.model.source;
import org.mapstruct.ap.internal.model.common.TypeFactory; import java.util.ArrayList;
import org.mapstruct.ap.internal.prism.CollectionMappingStrategyPrism; import java.util.Collections;
import org.mapstruct.ap.internal.prism.MappingPrism; import java.util.HashMap;
import org.mapstruct.ap.internal.prism.MappingsPrism; import java.util.List;
import org.mapstruct.ap.internal.util.FormattingMessager; import java.util.Map;
import org.mapstruct.ap.internal.util.Message; import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.AnnotationValue; import javax.lang.model.element.AnnotationValue;
@ -32,13 +33,13 @@ import javax.lang.model.element.ExecutableElement;
import javax.lang.model.type.DeclaredType; import javax.lang.model.type.DeclaredType;
import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeKind;
import javax.lang.model.type.TypeMirror; import javax.lang.model.type.TypeMirror;
import java.util.ArrayList;
import java.util.Collections; import org.mapstruct.ap.internal.model.common.TypeFactory;
import java.util.HashMap; import org.mapstruct.ap.internal.prism.CollectionMappingStrategyPrism;
import java.util.List; import org.mapstruct.ap.internal.prism.MappingPrism;
import java.util.Map; import org.mapstruct.ap.internal.prism.MappingsPrism;
import java.util.regex.Matcher; import org.mapstruct.ap.internal.util.FormattingMessager;
import java.util.regex.Pattern; import org.mapstruct.ap.internal.util.Message;
/** /**
* Represents a property mapping as configured via {@code @Mapping}. * Represents a property mapping as configured via {@code @Mapping}.
@ -106,34 +107,34 @@ public class Mapping {
return null; return null;
} }
if ( !mappingPrism.source().isEmpty() && !mappingPrism.constant().isEmpty() ) { if ( !mappingPrism.source().isEmpty() && mappingPrism.values.constant() != null ) {
messager.printMessage( element, Message.PROPERTYMAPPING_SOURCE_AND_CONSTANT_BOTH_DEFINED ); messager.printMessage( element, Message.PROPERTYMAPPING_SOURCE_AND_CONSTANT_BOTH_DEFINED );
return null; return null;
} }
else if ( !mappingPrism.source().isEmpty() && !mappingPrism.expression().isEmpty() ) { else if ( !mappingPrism.source().isEmpty() && mappingPrism.values.expression() != null ) {
messager.printMessage( element, Message.PROPERTYMAPPING_SOURCE_AND_EXPRESSION_BOTH_DEFINED ); messager.printMessage( element, Message.PROPERTYMAPPING_SOURCE_AND_EXPRESSION_BOTH_DEFINED );
return null; return null;
} }
else if ( !mappingPrism.expression().isEmpty() && !mappingPrism.constant().isEmpty() ) { else if ( mappingPrism.values.expression() != null && mappingPrism.values.constant() != null ) {
messager.printMessage( element, Message.PROPERTYMAPPING_EXPRESSION_AND_CONSTANT_BOTH_DEFINED ); messager.printMessage( element, Message.PROPERTYMAPPING_EXPRESSION_AND_CONSTANT_BOTH_DEFINED );
return null; return null;
} }
else if ( !mappingPrism.expression().isEmpty() && !mappingPrism.defaultValue().isEmpty() ) { else if ( mappingPrism.values.expression() != null && mappingPrism.values.defaultValue() != null ) {
messager.printMessage( element, Message.PROPERTYMAPPING_EXPRESSION_AND_DEFAULT_VALUE_BOTH_DEFINED ); messager.printMessage( element, Message.PROPERTYMAPPING_EXPRESSION_AND_DEFAULT_VALUE_BOTH_DEFINED );
return null; return null;
} }
else if ( !mappingPrism.constant().isEmpty() && !mappingPrism.defaultValue().isEmpty() ) { else if ( mappingPrism.values.constant() != null && mappingPrism.values.defaultValue() != null ) {
messager.printMessage( element, Message.PROPERTYMAPPING_CONSTANT_AND_DEFAULT_VALUE_BOTH_DEFINED ); messager.printMessage( element, Message.PROPERTYMAPPING_CONSTANT_AND_DEFAULT_VALUE_BOTH_DEFINED );
return null; return null;
} }
String source = mappingPrism.source().isEmpty() ? null : mappingPrism.source(); String source = mappingPrism.source().isEmpty() ? null : mappingPrism.source();
String constant = mappingPrism.constant().isEmpty() ? null : mappingPrism.constant(); String constant = mappingPrism.values.constant() == null ? null : mappingPrism.constant();
String expression = getExpression( mappingPrism, element, messager ); String expression = getExpression( mappingPrism, element, messager );
String dateFormat = mappingPrism.dateFormat().isEmpty() ? null : mappingPrism.dateFormat(); String dateFormat = mappingPrism.values.dateFormat() == null ? null : mappingPrism.dateFormat();
String defaultValue = mappingPrism.defaultValue().isEmpty() ? null : mappingPrism.defaultValue(); String defaultValue = mappingPrism.values.defaultValue() == null ? null : mappingPrism.defaultValue();
boolean resultTypeIsDefined = !TypeKind.VOID.equals( mappingPrism.resultType().getKind() ); boolean resultTypeIsDefined = mappingPrism.values.resultType() != null;
TypeMirror resultType = resultTypeIsDefined ? mappingPrism.resultType() : null; TypeMirror resultType = resultTypeIsDefined ? mappingPrism.resultType() : null;
List<String> dependsOn = List<String> dependsOn =
mappingPrism.dependsOn() != null ? mappingPrism.dependsOn() : Collections.<String>emptyList(); mappingPrism.dependsOn() != null ? mappingPrism.dependsOn() : Collections.<String>emptyList();

View File

@ -31,8 +31,7 @@ public enum ReportingPolicy {
IGNORE( null, false, false ), IGNORE( null, false, false ),
WARN( Kind.WARNING, true, false ), WARN( Kind.WARNING, true, false ),
ERROR( Kind.ERROR, true, true ), ERROR( Kind.ERROR, true, true );
DEFAULT( Kind.WARNING, true, false );
private final Diagnostic.Kind diagnosticKind; private final Diagnostic.Kind diagnosticKind;
private final boolean requiresReport; private final boolean requiresReport;

View File

@ -27,6 +27,5 @@ public enum CollectionMappingStrategyPrism {
ACCESSOR_ONLY, ACCESSOR_ONLY,
SETTER_PREFERRED, SETTER_PREFERRED,
ADDER_PREFERRED, ADDER_PREFERRED;
DEFAULT;
} }

View File

@ -26,6 +26,5 @@ package org.mapstruct.ap.internal.prism;
*/ */
public enum MappingInheritanceStrategyPrism { public enum MappingInheritanceStrategyPrism {
EXPLICIT, EXPLICIT,
AUTO_INHERIT_FROM_CONFIG, AUTO_INHERIT_FROM_CONFIG;
DEFAULT;
} }

View File

@ -26,6 +26,5 @@ package org.mapstruct.ap.internal.prism;
public enum NullValueMappingStrategyPrism { public enum NullValueMappingStrategyPrism {
RETURN_NULL, RETURN_NULL,
RETURN_DEFAULT, RETURN_DEFAULT;
DEFAULT;
} }

View File

@ -29,7 +29,6 @@ import javax.lang.model.type.DeclaredType;
import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeKind;
import javax.lang.model.type.TypeMirror; import javax.lang.model.type.TypeMirror;
import org.mapstruct.ap.internal.option.ReportingPolicy;
import org.mapstruct.ap.internal.prism.CollectionMappingStrategyPrism; import org.mapstruct.ap.internal.prism.CollectionMappingStrategyPrism;
import org.mapstruct.ap.internal.prism.MapperConfigPrism; import org.mapstruct.ap.internal.prism.MapperConfigPrism;
import org.mapstruct.ap.internal.prism.MapperPrism; import org.mapstruct.ap.internal.prism.MapperPrism;
@ -79,65 +78,37 @@ public class MapperConfiguration {
} }
public String unmappedTargetPolicy() { public String unmappedTargetPolicy() {
if ( ReportingPolicy.valueOf( mapperPrism.unmappedTargetPolicy() ) != ReportingPolicy.DEFAULT ) { if ( mapperConfigPrism != null && mapperPrism.values.unmappedTargetPolicy() == null ) {
// it is not the default configuration
return mapperPrism.unmappedTargetPolicy();
}
else if ( mapperConfigPrism != null &&
ReportingPolicy.valueOf( mapperConfigPrism.unmappedTargetPolicy() ) != ReportingPolicy.DEFAULT ) {
return mapperConfigPrism.unmappedTargetPolicy(); return mapperConfigPrism.unmappedTargetPolicy();
} }
else { else {
return ReportingPolicy.WARN.name(); return mapperPrism.unmappedTargetPolicy();
} }
} }
public CollectionMappingStrategyPrism getCollectionMappingStrategy() { public CollectionMappingStrategyPrism getCollectionMappingStrategy() {
CollectionMappingStrategyPrism mapperPolicy = if ( mapperConfigPrism != null && mapperPrism.values.collectionMappingStrategy() == null ) {
CollectionMappingStrategyPrism.valueOf( mapperPrism.collectionMappingStrategy() ); return CollectionMappingStrategyPrism.valueOf( mapperConfigPrism.collectionMappingStrategy() );
if ( mapperPolicy != CollectionMappingStrategyPrism.DEFAULT ) {
// it is not the default mapper configuration, so return the mapper configured value
return mapperPolicy;
} }
else if ( mapperConfigPrism != null ) { else {
// try the config mapper configuration return CollectionMappingStrategyPrism.valueOf( mapperPrism.collectionMappingStrategy() );
CollectionMappingStrategyPrism configPolicy =
CollectionMappingStrategyPrism.valueOf( mapperConfigPrism.collectionMappingStrategy() );
if ( configPolicy != CollectionMappingStrategyPrism.DEFAULT ) {
// its not the default configuration, so return the mapper config configured value
return configPolicy;
}
} }
// when nothing specified, return ACCESSOR_ONLY (default option)
return CollectionMappingStrategyPrism.ACCESSOR_ONLY;
} }
public MappingInheritanceStrategyPrism getMappingInheritanceStrategy() { public MappingInheritanceStrategyPrism getMappingInheritanceStrategy() {
MappingInheritanceStrategyPrism mapperPolicy = if ( mapperConfigPrism != null && mapperPrism.values.mappingInheritanceStrategy() == null ) {
MappingInheritanceStrategyPrism.valueOf( mapperPrism.mappingInheritanceStrategy() ); return MappingInheritanceStrategyPrism.valueOf( mapperConfigPrism.mappingInheritanceStrategy() );
if ( mapperPolicy != MappingInheritanceStrategyPrism.DEFAULT ) {
return mapperPolicy;
} }
else if ( mapperConfigPrism != null ) { else {
MappingInheritanceStrategyPrism configPolicy = return MappingInheritanceStrategyPrism.valueOf( mapperPrism.mappingInheritanceStrategy() );
MappingInheritanceStrategyPrism.valueOf( mapperConfigPrism.mappingInheritanceStrategy() );
if ( configPolicy != MappingInheritanceStrategyPrism.DEFAULT ) {
return configPolicy;
}
} }
return MappingInheritanceStrategyPrism.EXPLICIT;
} }
public boolean isMapToDefault(NullValueMappingStrategyPrism mapNullToDefault) { public boolean isMapToDefault(NullValueMappingStrategyPrism mapNullToDefault) {
// check on method level // check on method level
if ( mapNullToDefault != null ) { if ( mapNullToDefault != null ) {
if ( mapNullToDefault != NullValueMappingStrategyPrism.DEFAULT ) { return mapNullToDefault == NullValueMappingStrategyPrism.RETURN_DEFAULT;
return mapNullToDefault == NullValueMappingStrategyPrism.RETURN_DEFAULT;
}
} }
return isMapToDefaultOnMapperAndMappingConfigLevel(); return isMapToDefaultOnMapperAndMappingConfigLevel();
@ -145,40 +116,24 @@ public class MapperConfiguration {
} }
private boolean isMapToDefaultOnMapperAndMappingConfigLevel() { private boolean isMapToDefaultOnMapperAndMappingConfigLevel() {
final NullValueMappingStrategyPrism strategy;
// check on mapper level if ( mapperConfigPrism != null && mapperPrism.values.nullValueMappingStrategy() == null ) {
NullValueMappingStrategyPrism mapperPolicy = strategy = NullValueMappingStrategyPrism.valueOf( mapperConfigPrism.nullValueMappingStrategy() );
NullValueMappingStrategyPrism.valueOf( mapperPrism.nullValueMappingStrategy() ); }
else {
if ( mapperPolicy != NullValueMappingStrategyPrism.DEFAULT ) { strategy = NullValueMappingStrategyPrism.valueOf( mapperPrism.nullValueMappingStrategy() );
// it is not the default mapper configuration, so return the mapper configured value
return mapperPolicy == NullValueMappingStrategyPrism.RETURN_DEFAULT;
} }
// check on mapping config level return NullValueMappingStrategyPrism.RETURN_DEFAULT == strategy;
else if ( mapperConfigPrism != null ) {
// try the config mapper configuration
NullValueMappingStrategyPrism configPolicy =
NullValueMappingStrategyPrism.valueOf( mapperConfigPrism.nullValueMappingStrategy() );
if ( configPolicy != NullValueMappingStrategyPrism.DEFAULT ) {
// its not the default configuration, so return the mapper config configured value
return configPolicy == NullValueMappingStrategyPrism.RETURN_DEFAULT;
}
}
// when nothing specified, return RETURN_NULL (default option)
return false;
} }
public String componentModel() { public String componentModel() {
if ( !mapperPrism.componentModel().equals( "default" ) ) { if ( mapperConfigPrism != null && mapperPrism.values.componentModel() == null ) {
return mapperPrism.componentModel();
}
else if ( mapperConfigPrism != null ) {
return mapperConfigPrism.componentModel(); return mapperConfigPrism.componentModel();
} }
else { else {
return "default"; return mapperPrism.componentModel();
} }
} }

View File

@ -21,9 +21,9 @@ package org.mapstruct.ap.test.nullvaluemapping;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import org.mapstruct.IterableMapping; import org.mapstruct.IterableMapping;
import org.mapstruct.MapMapping; import org.mapstruct.MapMapping;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.Mapping; import org.mapstruct.Mapping;
import org.mapstruct.Mappings; import org.mapstruct.Mappings;
@ -45,7 +45,7 @@ public interface CarMapperSettingOnConfig {
CarDto carToCarDto(Car car); CarDto carToCarDto(Car car);
@IterableMapping(nullValueMappingStrategy = NullValueMappingStrategy.DEFAULT, dateFormat = "dummy") @IterableMapping(dateFormat = "dummy")
List<CarDto> carsToCarDtos(List<Car> cars); List<CarDto> carsToCarDtos(List<Car> cars);