diff --git a/core-common/src/main/java/org/mapstruct/BeanMapping.java b/core-common/src/main/java/org/mapstruct/BeanMapping.java index c26314638..04f95a38f 100644 --- a/core-common/src/main/java/org/mapstruct/BeanMapping.java +++ b/core-common/src/main/java/org/mapstruct/BeanMapping.java @@ -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. */ - NullValueMappingStrategy nullValueMappingStrategy() default NullValueMappingStrategy.DEFAULT; + NullValueMappingStrategy nullValueMappingStrategy() default NullValueMappingStrategy.RETURN_NULL; } diff --git a/core-common/src/main/java/org/mapstruct/CollectionMappingStrategy.java b/core-common/src/main/java/org/mapstruct/CollectionMappingStrategy.java index 4b2debd31..b58c7ab7c 100644 --- a/core-common/src/main/java/org/mapstruct/CollectionMappingStrategy.java +++ b/core-common/src/main/java/org/mapstruct/CollectionMappingStrategy.java @@ -51,12 +51,5 @@ public enum CollectionMappingStrategy { * 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. */ - 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; + ADDER_PREFERRED; } diff --git a/core-common/src/main/java/org/mapstruct/IterableMapping.java b/core-common/src/main/java/org/mapstruct/IterableMapping.java index 1e734b2fa..1d1ae6e43 100644 --- a/core-common/src/main/java/org/mapstruct/IterableMapping.java +++ b/core-common/src/main/java/org/mapstruct/IterableMapping.java @@ -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. */ - NullValueMappingStrategy nullValueMappingStrategy() default NullValueMappingStrategy.DEFAULT; + NullValueMappingStrategy nullValueMappingStrategy() default NullValueMappingStrategy.RETURN_NULL; } diff --git a/core-common/src/main/java/org/mapstruct/MapMapping.java b/core-common/src/main/java/org/mapstruct/MapMapping.java index 044c2e818..168bf3c83 100644 --- a/core-common/src/main/java/org/mapstruct/MapMapping.java +++ b/core-common/src/main/java/org/mapstruct/MapMapping.java @@ -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. */ - NullValueMappingStrategy nullValueMappingStrategy() default NullValueMappingStrategy.DEFAULT; + NullValueMappingStrategy nullValueMappingStrategy() default NullValueMappingStrategy.RETURN_NULL; } diff --git a/core-common/src/main/java/org/mapstruct/Mapper.java b/core-common/src/main/java/org/mapstruct/Mapper.java index 1e71500aa..b7b992c87 100644 --- a/core-common/src/main/java/org/mapstruct/Mapper.java +++ b/core-common/src/main/java/org/mapstruct/Mapper.java @@ -59,7 +59,7 @@ public @interface Mapper { * * @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 @@ -103,7 +103,7 @@ public @interface Mapper { * * @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 @@ -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. */ - 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 @@ -125,5 +125,5 @@ public @interface Mapper { * @return The strategy to use for applying {@code @Mapping} configurations of prototype methods in the interface * specified with {@link #config()}. */ - MappingInheritanceStrategy mappingInheritanceStrategy() default MappingInheritanceStrategy.DEFAULT; + MappingInheritanceStrategy mappingInheritanceStrategy() default MappingInheritanceStrategy.EXPLICIT; } diff --git a/core-common/src/main/java/org/mapstruct/MappingInheritanceStrategy.java b/core-common/src/main/java/org/mapstruct/MappingInheritanceStrategy.java index 678dde68f..7be5cdbe0 100644 --- a/core-common/src/main/java/org/mapstruct/MappingInheritanceStrategy.java +++ b/core-common/src/main/java/org/mapstruct/MappingInheritanceStrategy.java @@ -35,13 +35,5 @@ public enum MappingInheritanceStrategy { * 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. */ - AUTO_INHERIT_FROM_CONFIG, - - /** - * When given via {@link Mapper#mappingInheritanceStrategy()}, the value specified via - * {@link MapperConfig#mappingInheritanceStrategy()} will be applied, if present. - *
- * When given via {@link MapperConfig#mappingInheritanceStrategy()}, the strategy {@link #EXPLICIT} will be applied. - */ - DEFAULT; + AUTO_INHERIT_FROM_CONFIG; } diff --git a/core-common/src/main/java/org/mapstruct/NullValueMappingStrategy.java b/core-common/src/main/java/org/mapstruct/NullValueMappingStrategy.java index f2edf2cdd..433677f47 100644 --- a/core-common/src/main/java/org/mapstruct/NullValueMappingStrategy.java +++ b/core-common/src/main/java/org/mapstruct/NullValueMappingStrategy.java @@ -43,16 +43,5 @@ public enum NullValueMappingStrategy { *
- * When given on specific mapping methods (e.g. via @ BeanMapping#nullValueMappingStrategy()}), causes the setting - * specified via {@link Mapper#nullValueMappingStrategy() ()} to be applied, if present. - *
- * Otherwise causes {@link #RETURN_NULL} to be applied. - */ - DEFAULT; + RETURN_DEFAULT; } diff --git a/core-common/src/main/java/org/mapstruct/ReportingPolicy.java b/core-common/src/main/java/org/mapstruct/ReportingPolicy.java index 11266747c..8b322a068 100644 --- a/core-common/src/main/java/org/mapstruct/ReportingPolicy.java +++ b/core-common/src/main/java/org/mapstruct/ReportingPolicy.java @@ -42,15 +42,5 @@ public enum ReportingPolicy { * A report with {@link Kind#ERROR} will be created for the given issue, * causing the compilation to fail. */ - ERROR, - - /** - * When given as value for {@link Mapper#unmappedTargetPolicy()}, the setting from the configuration source - * referenced via {@link Mapper#config()} will be applied. - *
- * 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;
+ ERROR;
}
diff --git a/processor/src/main/java/org/mapstruct/ap/internal/model/source/BeanMapping.java b/processor/src/main/java/org/mapstruct/ap/internal/model/source/BeanMapping.java
index 957b08784..712040408 100644
--- a/processor/src/main/java/org/mapstruct/ap/internal/model/source/BeanMapping.java
+++ b/processor/src/main/java/org/mapstruct/ap/internal/model/source/BeanMapping.java
@@ -50,11 +50,13 @@ public class BeanMapping {
boolean resultTypeIsDefined = !TypeKind.VOID.equals( beanMapping.resultType().getKind() );
- NullValueMappingStrategyPrism nullValueMappingStrategy
- = NullValueMappingStrategyPrism.valueOf( beanMapping.nullValueMappingStrategy() );
+ NullValueMappingStrategyPrism nullValueMappingStrategy =
+ null == beanMapping.values.nullValueMappingStrategy()
+ ? null
+ : NullValueMappingStrategyPrism.valueOf( beanMapping.nullValueMappingStrategy() );
if ( !resultTypeIsDefined && beanMapping.qualifiedBy().isEmpty()
- && ( nullValueMappingStrategy == NullValueMappingStrategyPrism.DEFAULT ) ) {
+ && ( nullValueMappingStrategy == null ) ) {
messager.printMessage( method, Message.BEANMAPPING_NO_ELEMENTS );
}
diff --git a/processor/src/main/java/org/mapstruct/ap/internal/model/source/IterableMapping.java b/processor/src/main/java/org/mapstruct/ap/internal/model/source/IterableMapping.java
index b913288e7..8359ba1cd 100644
--- a/processor/src/main/java/org/mapstruct/ap/internal/model/source/IterableMapping.java
+++ b/processor/src/main/java/org/mapstruct/ap/internal/model/source/IterableMapping.java
@@ -53,13 +53,15 @@ public class IterableMapping {
boolean elementTargetTypeIsDefined = !TypeKind.VOID.equals( iterableMapping.elementTargetType().getKind() );
- NullValueMappingStrategyPrism nullValueMappingStrategy
- = NullValueMappingStrategyPrism.valueOf( iterableMapping.nullValueMappingStrategy() );
+ NullValueMappingStrategyPrism nullValueMappingStrategy =
+ iterableMapping.values.nullValueMappingStrategy() == null
+ ? null
+ : NullValueMappingStrategyPrism.valueOf( iterableMapping.nullValueMappingStrategy() );
if ( !elementTargetTypeIsDefined
&& iterableMapping.dateFormat().isEmpty()
&& iterableMapping.qualifiedBy().isEmpty()
- && ( nullValueMappingStrategy == NullValueMappingStrategyPrism.DEFAULT ) ) {
+ && ( nullValueMappingStrategy == null ) ) {
messager.printMessage( method, Message.ITERABLEMAPPING_NO_ELEMENTS );
}
diff --git a/processor/src/main/java/org/mapstruct/ap/internal/model/source/MapMapping.java b/processor/src/main/java/org/mapstruct/ap/internal/model/source/MapMapping.java
index da2a0901a..12e0b1556 100644
--- a/processor/src/main/java/org/mapstruct/ap/internal/model/source/MapMapping.java
+++ b/processor/src/main/java/org/mapstruct/ap/internal/model/source/MapMapping.java
@@ -52,8 +52,10 @@ public class MapMapping {
return null;
}
- NullValueMappingStrategyPrism nullValueMappingStrategy
- = NullValueMappingStrategyPrism.valueOf( mapMapping.nullValueMappingStrategy() );
+ NullValueMappingStrategyPrism nullValueMappingStrategy =
+ mapMapping.values.nullValueMappingStrategy() == null
+ ? null
+ : NullValueMappingStrategyPrism.valueOf( mapMapping.nullValueMappingStrategy() );
boolean keyTargetTypeIsDefined = !TypeKind.VOID.equals( mapMapping.keyTargetType().getKind() );
@@ -64,7 +66,7 @@ public class MapMapping {
&& mapMapping.valueQualifiedBy().isEmpty()
&& !keyTargetTypeIsDefined
&& !valueTargetTypeIsDefined
- && ( nullValueMappingStrategy == NullValueMappingStrategyPrism.DEFAULT ) ) {
+ && ( nullValueMappingStrategy == null ) ) {
messager.printMessage( method, Message.MAPMAPPING_NO_ELEMENTS );
}
diff --git a/processor/src/main/java/org/mapstruct/ap/internal/model/source/Mapping.java b/processor/src/main/java/org/mapstruct/ap/internal/model/source/Mapping.java
index 2f330c774..4d0144fa0 100644
--- a/processor/src/main/java/org/mapstruct/ap/internal/model/source/Mapping.java
+++ b/processor/src/main/java/org/mapstruct/ap/internal/model/source/Mapping.java
@@ -18,12 +18,13 @@
*/
package org.mapstruct.ap.internal.model.source;
-import org.mapstruct.ap.internal.model.common.TypeFactory;
-import org.mapstruct.ap.internal.prism.CollectionMappingStrategyPrism;
-import org.mapstruct.ap.internal.prism.MappingPrism;
-import org.mapstruct.ap.internal.prism.MappingsPrism;
-import org.mapstruct.ap.internal.util.FormattingMessager;
-import org.mapstruct.ap.internal.util.Message;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import javax.lang.model.element.AnnotationMirror;
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.TypeKind;
import javax.lang.model.type.TypeMirror;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
+
+import org.mapstruct.ap.internal.model.common.TypeFactory;
+import org.mapstruct.ap.internal.prism.CollectionMappingStrategyPrism;
+import org.mapstruct.ap.internal.prism.MappingPrism;
+import org.mapstruct.ap.internal.prism.MappingsPrism;
+import org.mapstruct.ap.internal.util.FormattingMessager;
+import org.mapstruct.ap.internal.util.Message;
/**
* Represents a property mapping as configured via {@code @Mapping}.
@@ -106,34 +107,34 @@ public class Mapping {
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 );
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 );
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 );
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 );
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 );
return null;
}
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 dateFormat = mappingPrism.dateFormat().isEmpty() ? null : mappingPrism.dateFormat();
- String defaultValue = mappingPrism.defaultValue().isEmpty() ? null : mappingPrism.defaultValue();
+ String dateFormat = mappingPrism.values.dateFormat() == null ? null : mappingPrism.dateFormat();
+ 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;
List