From 4223e3ab812a496aeb31b67a63737fb648bd2ddb Mon Sep 17 00:00:00 2001
From: Tomas Poledny
* // we have MarkMapper (map field "mark" to field "name" to upper case)
- * @Mapper(componentModel = "spring")
+ * @Mapper(componentModel = MappingConstants.ComponentModel.SPRING)
* public class MarkMapper {
* public String mapMark(String mark) {
* return mark.toUpperCase();
@@ -43,7 +43,7 @@ import static org.mapstruct.NullValueCheckStrategy.ON_IMPLICIT_CONVERSION;
* }
* // we have CarMapper
* @Mapper(
- * componentModel = "spring",
+ * componentModel = MappingConstants.ComponentModel.SPRING,
* uses = MarkMapper.class,
* injectionStrategy = InjectionStrategy.CONSTRUCTOR)
* public interface CarMapper {
@@ -148,7 +148,7 @@ public @interface Mapper {
*
* @return The component model for the generated mapper.
*/
- String componentModel() default "default";
+ String componentModel() default MappingConstants.ComponentModel.DEFAULT;
/**
* Specifies the name of the implementation class. The {@code } will be replaced by the
diff --git a/core/src/main/java/org/mapstruct/MapperConfig.java b/core/src/main/java/org/mapstruct/MapperConfig.java
index d251ff379..ecfd888ca 100644
--- a/core/src/main/java/org/mapstruct/MapperConfig.java
+++ b/core/src/main/java/org/mapstruct/MapperConfig.java
@@ -135,7 +135,7 @@ public @interface MapperConfig {
*
* @return The component model for the generated mapper.
*/
- String componentModel() default "default";
+ String componentModel() default MappingConstants.ComponentModel.DEFAULT;
/**
* Specifies the name of the implementation class. The {@code } will be replaced by the
diff --git a/core/src/main/java/org/mapstruct/MappingConstants.java b/core/src/main/java/org/mapstruct/MappingConstants.java
index 2c5757038..6e30f08c2 100644
--- a/core/src/main/java/org/mapstruct/MappingConstants.java
+++ b/core/src/main/java/org/mapstruct/MappingConstants.java
@@ -66,4 +66,49 @@ public final class MappingConstants {
*/
public static final String STRIP_PREFIX_TRANSFORMATION = "stripPrefix";
+ /**
+ * Specifies the component model constants to which the generated mapper should adhere.
+ * It can be used with the annotation {@link Mapper#componentModel()} or {@link MapperConfig#componentModel()}
+ *
+ *
+ * Example:
+ *
+ *
+ * // Spring component model
+ * @Mapper(componentModel = MappingConstants.ComponentModel.SPRING)
+ *
+ *
+ * @since 1.5.0
+ */
+ public static final class ComponentModel {
+
+ private ComponentModel() {
+ }
+
+ /**
+ * The mapper uses no component model, instances are typically retrieved
+ * via {@link org.mapstruct.factory.Mappers#getMapper(java.lang.Class)}
+ *
+ */
+ public static final String DEFAULT = "default";
+
+ /**
+ * The generated mapper is an application-scoped CDI bean and can be retrieved via @Inject
+ */
+ public static final String CDI = "cdi";
+
+ /**
+ * The generated mapper is a Spring bean and can be retrieved via @Autowired
+ *
+ */
+ public static final String SPRING = "spring";
+
+ /**
+ * The generated mapper is annotated with @javax.inject.Named and @Singleton, and can be retrieved via @Inject
+ *
+ */
+ public static final String JSR330 = "jsr330";
+
+ }
+
}
diff --git a/documentation/src/main/asciidoc/chapter-4-retrieving-a-mapper.asciidoc b/documentation/src/main/asciidoc/chapter-4-retrieving-a-mapper.asciidoc
index 75b5b1029..724b42fbb 100644
--- a/documentation/src/main/asciidoc/chapter-4-retrieving-a-mapper.asciidoc
+++ b/documentation/src/main/asciidoc/chapter-4-retrieving-a-mapper.asciidoc
@@ -69,14 +69,14 @@ Note that mappers generated by MapStruct are stateless and thread-safe and thus
If you're working with a dependency injection framework such as http://jcp.org/en/jsr/detail?id=346[CDI] (Contexts and Dependency Injection for Java^TM^ EE) or the http://www.springsource.org/spring-framework[Spring Framework], it is recommended to obtain mapper objects via dependency injection and *not* via the `Mappers` class as described above. For that purpose you can specify the component model which generated mapper classes should be based on either via `@Mapper#componentModel` or using a processor option as described in <>.
-Currently there is support for CDI and Spring (the latter either via its custom annotations or using the JSR 330 annotations). See <> for the allowed values of the `componentModel` attribute which are the same as for the `mapstruct.defaultComponentModel` processor option. In both cases the required annotations will be added to the generated mapper implementations classes in order to make the same subject to dependency injection. The following shows an example using CDI:
+Currently there is support for CDI and Spring (the latter either via its custom annotations or using the JSR 330 annotations). See <> for the allowed values of the `componentModel` attribute which are the same as for the `mapstruct.defaultComponentModel` processor option and constants are defined in a class `MappingConstants.ComponentModel`. In both cases the required annotations will be added to the generated mapper implementations classes in order to make the same subject to dependency injection. The following shows an example using CDI:
.A mapper using the CDI component model
====
[source, java, linenums]
[subs="verbatim,attributes"]
----
-@Mapper(componentModel = "cdi")
+@Mapper(componentModel = MappingConstants.ComponentModel.CDI)
public interface CarMapper {
CarDto carToCarDto(Car car);
@@ -110,7 +110,7 @@ This can be done by either providing the injection strategy via `@Mapper` or `@M
[source, java, linenums]
[subs="verbatim,attributes"]
----
-@Mapper(componentModel = "cdi", uses = EngineMapper.class, injectionStrategy = InjectionStrategy.CONSTRUCTOR)
+@Mapper(componentModel = MappingConstants.ComponentModel.CDI, uses = EngineMapper.class, injectionStrategy = InjectionStrategy.CONSTRUCTOR)
public interface CarMapper {
CarDto carToCarDto(Car car);
}
diff --git a/documentation/src/main/asciidoc/chapter-5-data-type-conversions.asciidoc b/documentation/src/main/asciidoc/chapter-5-data-type-conversions.asciidoc
index 9619d0fe2..9978cd3f2 100644
--- a/documentation/src/main/asciidoc/chapter-5-data-type-conversions.asciidoc
+++ b/documentation/src/main/asciidoc/chapter-5-data-type-conversions.asciidoc
@@ -405,7 +405,7 @@ public class ReferenceMapper {
}
}
-@Mapper(componentModel = "cdi", uses = ReferenceMapper.class )
+@Mapper(componentModel = MappingConstants.ComponentModel.CDI, uses = ReferenceMapper.class )
public interface CarMapper {
Car carDtoToCar(CarDto carDto);
diff --git a/integrationtest/src/test/resources/cdiTest/src/main/java/org/mapstruct/itest/cdi/DecoratedSourceTargetMapper.java b/integrationtest/src/test/resources/cdiTest/src/main/java/org/mapstruct/itest/cdi/DecoratedSourceTargetMapper.java
index 1787fd3c9..18a57ce25 100644
--- a/integrationtest/src/test/resources/cdiTest/src/main/java/org/mapstruct/itest/cdi/DecoratedSourceTargetMapper.java
+++ b/integrationtest/src/test/resources/cdiTest/src/main/java/org/mapstruct/itest/cdi/DecoratedSourceTargetMapper.java
@@ -6,10 +6,11 @@
package org.mapstruct.itest.cdi;
import org.mapstruct.Mapper;
+import org.mapstruct.MappingConstants;
import org.mapstruct.DecoratedWith;
import org.mapstruct.itest.cdi.other.DateMapper;
-@Mapper( componentModel = "cdi", uses = DateMapper.class )
+@Mapper( componentModel = MappingConstants.ComponentModel.CDI, uses = DateMapper.class )
public interface DecoratedSourceTargetMapper {
Target sourceToTarget(Source source);
diff --git a/integrationtest/src/test/resources/cdiTest/src/main/java/org/mapstruct/itest/cdi/SourceTargetMapper.java b/integrationtest/src/test/resources/cdiTest/src/main/java/org/mapstruct/itest/cdi/SourceTargetMapper.java
index 3a46a2088..eb895f5e5 100644
--- a/integrationtest/src/test/resources/cdiTest/src/main/java/org/mapstruct/itest/cdi/SourceTargetMapper.java
+++ b/integrationtest/src/test/resources/cdiTest/src/main/java/org/mapstruct/itest/cdi/SourceTargetMapper.java
@@ -6,9 +6,10 @@
package org.mapstruct.itest.cdi;
import org.mapstruct.Mapper;
+import org.mapstruct.MappingConstants;
import org.mapstruct.itest.cdi.other.DateMapper;
-@Mapper(componentModel = "cdi", uses = DateMapper.class)
+@Mapper(componentModel = MappingConstants.ComponentModel.CDI, uses = DateMapper.class)
public interface SourceTargetMapper {
Target sourceToTarget(Source source);
diff --git a/integrationtest/src/test/resources/jsr330Test/src/main/java/org/mapstruct/itest/jsr330/DecoratedSourceTargetMapper.java b/integrationtest/src/test/resources/jsr330Test/src/main/java/org/mapstruct/itest/jsr330/DecoratedSourceTargetMapper.java
index 137f234c2..77f5ec558 100644
--- a/integrationtest/src/test/resources/jsr330Test/src/main/java/org/mapstruct/itest/jsr330/DecoratedSourceTargetMapper.java
+++ b/integrationtest/src/test/resources/jsr330Test/src/main/java/org/mapstruct/itest/jsr330/DecoratedSourceTargetMapper.java
@@ -6,10 +6,11 @@
package org.mapstruct.itest.jsr330;
import org.mapstruct.Mapper;
+import org.mapstruct.MappingConstants;
import org.mapstruct.DecoratedWith;
import org.mapstruct.itest.jsr330.other.DateMapper;
-@Mapper(componentModel = "jsr330", uses = DateMapper.class)
+@Mapper(componentModel = MappingConstants.ComponentModel.JSR330, uses = DateMapper.class)
@DecoratedWith(SourceTargetMapperDecorator.class)
public interface DecoratedSourceTargetMapper {
diff --git a/integrationtest/src/test/resources/jsr330Test/src/main/java/org/mapstruct/itest/jsr330/SecondDecoratedSourceTargetMapper.java b/integrationtest/src/test/resources/jsr330Test/src/main/java/org/mapstruct/itest/jsr330/SecondDecoratedSourceTargetMapper.java
index cdec6dc19..f088e21de 100644
--- a/integrationtest/src/test/resources/jsr330Test/src/main/java/org/mapstruct/itest/jsr330/SecondDecoratedSourceTargetMapper.java
+++ b/integrationtest/src/test/resources/jsr330Test/src/main/java/org/mapstruct/itest/jsr330/SecondDecoratedSourceTargetMapper.java
@@ -6,10 +6,11 @@
package org.mapstruct.itest.jsr330;
import org.mapstruct.Mapper;
+import org.mapstruct.MappingConstants;
import org.mapstruct.DecoratedWith;
import org.mapstruct.itest.jsr330.other.DateMapper;
-@Mapper(componentModel = "jsr330", uses = DateMapper.class)
+@Mapper(componentModel = MappingConstants.ComponentModel.JSR330, uses = DateMapper.class)
@DecoratedWith(SecondSourceTargetMapperDecorator.class)
public interface SecondDecoratedSourceTargetMapper {
diff --git a/integrationtest/src/test/resources/jsr330Test/src/main/java/org/mapstruct/itest/jsr330/SourceTargetMapper.java b/integrationtest/src/test/resources/jsr330Test/src/main/java/org/mapstruct/itest/jsr330/SourceTargetMapper.java
index c5ba3670f..a96a860da 100644
--- a/integrationtest/src/test/resources/jsr330Test/src/main/java/org/mapstruct/itest/jsr330/SourceTargetMapper.java
+++ b/integrationtest/src/test/resources/jsr330Test/src/main/java/org/mapstruct/itest/jsr330/SourceTargetMapper.java
@@ -6,9 +6,10 @@
package org.mapstruct.itest.jsr330;
import org.mapstruct.Mapper;
+import org.mapstruct.MappingConstants;
import org.mapstruct.itest.jsr330.other.DateMapper;
-@Mapper(componentModel = "jsr330", uses = DateMapper.class)
+@Mapper(componentModel = MappingConstants.ComponentModel.JSR330, uses = DateMapper.class)
public interface SourceTargetMapper {
Target sourceToTarget(Source source);
diff --git a/integrationtest/src/test/resources/springTest/src/main/java/org/mapstruct/itest/spring/DecoratedSourceTargetMapper.java b/integrationtest/src/test/resources/springTest/src/main/java/org/mapstruct/itest/spring/DecoratedSourceTargetMapper.java
index f1bbf87d3..a020ab2b2 100644
--- a/integrationtest/src/test/resources/springTest/src/main/java/org/mapstruct/itest/spring/DecoratedSourceTargetMapper.java
+++ b/integrationtest/src/test/resources/springTest/src/main/java/org/mapstruct/itest/spring/DecoratedSourceTargetMapper.java
@@ -6,10 +6,11 @@
package org.mapstruct.itest.spring;
import org.mapstruct.Mapper;
+import org.mapstruct.MappingConstants;
import org.mapstruct.DecoratedWith;
import org.mapstruct.itest.spring.other.DateMapper;
-@Mapper( componentModel = "spring", uses = DateMapper.class )
+@Mapper( componentModel = MappingConstants.ComponentModel.SPRING, uses = DateMapper.class )
@DecoratedWith( SourceTargetMapperDecorator.class )
public interface DecoratedSourceTargetMapper {
diff --git a/integrationtest/src/test/resources/springTest/src/main/java/org/mapstruct/itest/spring/SecondDecoratedSourceTargetMapper.java b/integrationtest/src/test/resources/springTest/src/main/java/org/mapstruct/itest/spring/SecondDecoratedSourceTargetMapper.java
index 88e290630..7c0426259 100644
--- a/integrationtest/src/test/resources/springTest/src/main/java/org/mapstruct/itest/spring/SecondDecoratedSourceTargetMapper.java
+++ b/integrationtest/src/test/resources/springTest/src/main/java/org/mapstruct/itest/spring/SecondDecoratedSourceTargetMapper.java
@@ -6,10 +6,11 @@
package org.mapstruct.itest.spring;
import org.mapstruct.Mapper;
+import org.mapstruct.MappingConstants;
import org.mapstruct.DecoratedWith;
import org.mapstruct.itest.spring.other.DateMapper;
-@Mapper( componentModel = "spring", uses = DateMapper.class )
+@Mapper( componentModel = MappingConstants.ComponentModel.SPRING, uses = DateMapper.class )
@DecoratedWith( SecondSourceTargetMapperDecorator.class )
public interface SecondDecoratedSourceTargetMapper {
diff --git a/integrationtest/src/test/resources/springTest/src/main/java/org/mapstruct/itest/spring/SourceTargetMapper.java b/integrationtest/src/test/resources/springTest/src/main/java/org/mapstruct/itest/spring/SourceTargetMapper.java
index 06e4be4d2..e6d6b4633 100644
--- a/integrationtest/src/test/resources/springTest/src/main/java/org/mapstruct/itest/spring/SourceTargetMapper.java
+++ b/integrationtest/src/test/resources/springTest/src/main/java/org/mapstruct/itest/spring/SourceTargetMapper.java
@@ -6,9 +6,10 @@
package org.mapstruct.itest.spring;
import org.mapstruct.Mapper;
+import org.mapstruct.MappingConstants;
import org.mapstruct.itest.spring.other.DateMapper;
-@Mapper(componentModel = "spring", uses = DateMapper.class)
+@Mapper(componentModel = MappingConstants.ComponentModel.SPRING, uses = DateMapper.class)
public interface SourceTargetMapper {
Target sourceToTarget(Source source);
diff --git a/processor/src/main/java/org/mapstruct/ap/internal/gem/MappingConstantsGem.java b/processor/src/main/java/org/mapstruct/ap/internal/gem/MappingConstantsGem.java
index 685f5a543..5df7fd3f9 100644
--- a/processor/src/main/java/org/mapstruct/ap/internal/gem/MappingConstantsGem.java
+++ b/processor/src/main/java/org/mapstruct/ap/internal/gem/MappingConstantsGem.java
@@ -28,4 +28,23 @@ public final class MappingConstantsGem {
public static final String PREFIX_TRANSFORMATION = "prefix";
public static final String STRIP_PREFIX_TRANSFORMATION = "stripPrefix";
+
+ /**
+ * Gem for the class {@link org.mapstruct.MappingConstants.ComponentModel}
+ *
+ */
+ public final class ComponentModelGem {
+
+ private ComponentModelGem() {
+ }
+
+ public static final String DEFAULT = "default";
+
+ public static final String CDI = "cdi";
+
+ public static final String SPRING = "spring";
+
+ public static final String JSR330 = "jsr330";
+ }
+
}
diff --git a/processor/src/main/java/org/mapstruct/ap/internal/processor/CdiComponentProcessor.java b/processor/src/main/java/org/mapstruct/ap/internal/processor/CdiComponentProcessor.java
index a5e345868..74ff2b118 100644
--- a/processor/src/main/java/org/mapstruct/ap/internal/processor/CdiComponentProcessor.java
+++ b/processor/src/main/java/org/mapstruct/ap/internal/processor/CdiComponentProcessor.java
@@ -9,6 +9,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
+import org.mapstruct.ap.internal.gem.MappingConstantsGem;
import org.mapstruct.ap.internal.model.Annotation;
import org.mapstruct.ap.internal.model.Mapper;
@@ -23,7 +24,7 @@ public class CdiComponentProcessor extends AnnotationBasedComponentModelProcesso
@Override
protected String getComponentModelIdentifier() {
- return "cdi";
+ return MappingConstantsGem.ComponentModelGem.CDI;
}
@Override
diff --git a/processor/src/main/java/org/mapstruct/ap/internal/processor/Jsr330ComponentProcessor.java b/processor/src/main/java/org/mapstruct/ap/internal/processor/Jsr330ComponentProcessor.java
index 4f7b46d64..18a6e4f69 100644
--- a/processor/src/main/java/org/mapstruct/ap/internal/processor/Jsr330ComponentProcessor.java
+++ b/processor/src/main/java/org/mapstruct/ap/internal/processor/Jsr330ComponentProcessor.java
@@ -9,6 +9,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
+import org.mapstruct.ap.internal.gem.MappingConstantsGem;
import org.mapstruct.ap.internal.model.Annotation;
import org.mapstruct.ap.internal.model.Mapper;
@@ -23,7 +24,7 @@ import org.mapstruct.ap.internal.model.Mapper;
public class Jsr330ComponentProcessor extends AnnotationBasedComponentModelProcessor {
@Override
protected String getComponentModelIdentifier() {
- return "jsr330";
+ return MappingConstantsGem.ComponentModelGem.JSR330;
}
@Override
diff --git a/processor/src/main/java/org/mapstruct/ap/internal/processor/MapperServiceProcessor.java b/processor/src/main/java/org/mapstruct/ap/internal/processor/MapperServiceProcessor.java
index f74a84c49..c9e37596f 100644
--- a/processor/src/main/java/org/mapstruct/ap/internal/processor/MapperServiceProcessor.java
+++ b/processor/src/main/java/org/mapstruct/ap/internal/processor/MapperServiceProcessor.java
@@ -11,6 +11,7 @@ import javax.lang.model.element.TypeElement;
import javax.tools.FileObject;
import javax.tools.StandardLocation;
+import org.mapstruct.ap.internal.gem.MappingConstantsGem;
import org.mapstruct.ap.internal.model.GeneratedType;
import org.mapstruct.ap.internal.model.Mapper;
import org.mapstruct.ap.internal.model.ServicesEntry;
@@ -38,7 +39,7 @@ public class MapperServiceProcessor implements ModelElementProcessorJsr330Impl", componentModel = "jsr330")
+@Mapper(implementationName = "Jsr330Impl", componentModel = MappingConstants.ComponentModel.JSR330)
public interface DestinationClassNameWithJsr330Mapper {
String intToString(Integer source);
}
diff --git a/processor/src/test/java/org/mapstruct/ap/test/gem/ConstantTest.java b/processor/src/test/java/org/mapstruct/ap/test/gem/ConstantTest.java
index a2a6afefd..69fa56a31 100644
--- a/processor/src/test/java/org/mapstruct/ap/test/gem/ConstantTest.java
+++ b/processor/src/test/java/org/mapstruct/ap/test/gem/ConstantTest.java
@@ -30,4 +30,13 @@ public class ConstantTest {
assertThat( MappingConstants.STRIP_PREFIX_TRANSFORMATION )
.isEqualTo( MappingConstantsGem.STRIP_PREFIX_TRANSFORMATION );
}
+
+ @Test
+ public void componentModelContantsShouldBeEqual() {
+ assertThat( MappingConstants.ComponentModel.DEFAULT )
+ .isEqualTo( MappingConstantsGem.ComponentModelGem.DEFAULT );
+ assertThat( MappingConstants.ComponentModel.CDI ).isEqualTo( MappingConstantsGem.ComponentModelGem.CDI );
+ assertThat( MappingConstants.ComponentModel.SPRING ).isEqualTo( MappingConstantsGem.ComponentModelGem.SPRING );
+ assertThat( MappingConstants.ComponentModel.JSR330 ).isEqualTo( MappingConstantsGem.ComponentModelGem.JSR330 );
+ }
}
diff --git a/processor/src/test/java/org/mapstruct/ap/test/imports/SourceTargetMapper.java b/processor/src/test/java/org/mapstruct/ap/test/imports/SourceTargetMapper.java
index 8e5e7b0de..1380ca400 100644
--- a/processor/src/test/java/org/mapstruct/ap/test/imports/SourceTargetMapper.java
+++ b/processor/src/test/java/org/mapstruct/ap/test/imports/SourceTargetMapper.java
@@ -8,6 +8,7 @@ package org.mapstruct.ap.test.imports;
import java.util.Date;
import org.mapstruct.Mapper;
+import org.mapstruct.MappingConstants;
import org.mapstruct.ap.test.imports.referenced.Source;
import org.mapstruct.ap.test.imports.referenced.Target;
import org.mapstruct.ap.test.imports.to.Foo;
@@ -16,7 +17,7 @@ import org.mapstruct.factory.Mappers;
/**
* @author Gunnar Morling
*/
-@Mapper(componentModel = "jsr330")
+@Mapper(componentModel = MappingConstants.ComponentModel.JSR330)
public interface SourceTargetMapper {
SourceTargetMapper INSTANCE = Mappers.getMapper( SourceTargetMapper.class );
diff --git a/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/jsr330/_default/CustomerJsr330DefaultCompileOptionFieldMapper.java b/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/jsr330/_default/CustomerJsr330DefaultCompileOptionFieldMapper.java
index 9ce6b1215..7fcbe97d5 100644
--- a/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/jsr330/_default/CustomerJsr330DefaultCompileOptionFieldMapper.java
+++ b/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/jsr330/_default/CustomerJsr330DefaultCompileOptionFieldMapper.java
@@ -6,13 +6,15 @@
package org.mapstruct.ap.test.injectionstrategy.jsr330._default;
import org.mapstruct.Mapper;
+import org.mapstruct.MappingConstants;
import org.mapstruct.ap.test.injectionstrategy.shared.CustomerDto;
import org.mapstruct.ap.test.injectionstrategy.shared.CustomerEntity;
/**
* @author Andrei Arlou
*/
-@Mapper(componentModel = "jsr330", uses = GenderJsr330DefaultCompileOptionFieldMapper.class)
+@Mapper(componentModel = MappingConstants.ComponentModel.JSR330,
+ uses = GenderJsr330DefaultCompileOptionFieldMapper.class)
public interface CustomerJsr330DefaultCompileOptionFieldMapper {
CustomerDto asTarget(CustomerEntity customerEntity);
diff --git a/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/jsr330/_default/GenderJsr330DefaultCompileOptionFieldMapper.java b/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/jsr330/_default/GenderJsr330DefaultCompileOptionFieldMapper.java
index 6701ce42f..1ecf720cb 100644
--- a/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/jsr330/_default/GenderJsr330DefaultCompileOptionFieldMapper.java
+++ b/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/jsr330/_default/GenderJsr330DefaultCompileOptionFieldMapper.java
@@ -6,6 +6,7 @@
package org.mapstruct.ap.test.injectionstrategy.jsr330._default;
import org.mapstruct.Mapper;
+import org.mapstruct.MappingConstants;
import org.mapstruct.ValueMapping;
import org.mapstruct.ValueMappings;
import org.mapstruct.ap.test.injectionstrategy.shared.Gender;
@@ -14,7 +15,7 @@ import org.mapstruct.ap.test.injectionstrategy.shared.GenderDto;
/**
* @author Andrei Arlou
*/
-@Mapper(componentModel = "jsr330")
+@Mapper(componentModel = MappingConstants.ComponentModel.JSR330)
public interface GenderJsr330DefaultCompileOptionFieldMapper {
@ValueMappings({
diff --git a/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/jsr330/compileoptionconstructor/CustomerJsr330CompileOptionConstructorMapper.java b/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/jsr330/compileoptionconstructor/CustomerJsr330CompileOptionConstructorMapper.java
index 0e89ec894..143c45288 100644
--- a/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/jsr330/compileoptionconstructor/CustomerJsr330CompileOptionConstructorMapper.java
+++ b/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/jsr330/compileoptionconstructor/CustomerJsr330CompileOptionConstructorMapper.java
@@ -7,13 +7,14 @@ package org.mapstruct.ap.test.injectionstrategy.jsr330.compileoptionconstructor;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
+import org.mapstruct.MappingConstants;
import org.mapstruct.ap.test.injectionstrategy.shared.CustomerDto;
import org.mapstruct.ap.test.injectionstrategy.shared.CustomerEntity;
/**
* @author Andrei Arlou
*/
-@Mapper( componentModel = "jsr330",
+@Mapper( componentModel = MappingConstants.ComponentModel.JSR330,
uses = GenderJsr330CompileOptionConstructorMapper.class )
public interface CustomerJsr330CompileOptionConstructorMapper {
diff --git a/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/jsr330/compileoptionconstructor/GenderJsr330CompileOptionConstructorMapper.java b/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/jsr330/compileoptionconstructor/GenderJsr330CompileOptionConstructorMapper.java
index da3caed5b..bffcc06bb 100644
--- a/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/jsr330/compileoptionconstructor/GenderJsr330CompileOptionConstructorMapper.java
+++ b/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/jsr330/compileoptionconstructor/GenderJsr330CompileOptionConstructorMapper.java
@@ -6,6 +6,7 @@
package org.mapstruct.ap.test.injectionstrategy.jsr330.compileoptionconstructor;
import org.mapstruct.Mapper;
+import org.mapstruct.MappingConstants;
import org.mapstruct.ValueMapping;
import org.mapstruct.ValueMappings;
import org.mapstruct.ap.test.injectionstrategy.shared.Gender;
@@ -14,7 +15,7 @@ import org.mapstruct.ap.test.injectionstrategy.shared.GenderDto;
/**
* @author Andrei Arlou
*/
-@Mapper(componentModel = "jsr330")
+@Mapper(componentModel = MappingConstants.ComponentModel.JSR330)
public interface GenderJsr330CompileOptionConstructorMapper {
@ValueMappings({
diff --git a/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/jsr330/constructor/ConstructorJsr330Config.java b/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/jsr330/constructor/ConstructorJsr330Config.java
index 3bfc7d23a..177b70d1d 100644
--- a/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/jsr330/constructor/ConstructorJsr330Config.java
+++ b/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/jsr330/constructor/ConstructorJsr330Config.java
@@ -7,10 +7,12 @@ package org.mapstruct.ap.test.injectionstrategy.jsr330.constructor;
import org.mapstruct.InjectionStrategy;
import org.mapstruct.MapperConfig;
+import org.mapstruct.MappingConstants;
/**
* @author Filip Hrisafov
*/
-@MapperConfig(componentModel = "jsr330", injectionStrategy = InjectionStrategy.CONSTRUCTOR)
+@MapperConfig(componentModel = MappingConstants.ComponentModel.JSR330,
+ injectionStrategy = InjectionStrategy.CONSTRUCTOR)
public interface ConstructorJsr330Config {
}
diff --git a/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/jsr330/constructor/CustomerJsr330ConstructorMapper.java b/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/jsr330/constructor/CustomerJsr330ConstructorMapper.java
index 001cb9f73..638e71a3a 100644
--- a/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/jsr330/constructor/CustomerJsr330ConstructorMapper.java
+++ b/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/jsr330/constructor/CustomerJsr330ConstructorMapper.java
@@ -8,13 +8,14 @@ package org.mapstruct.ap.test.injectionstrategy.jsr330.constructor;
import org.mapstruct.InjectionStrategy;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
+import org.mapstruct.MappingConstants;
import org.mapstruct.ap.test.injectionstrategy.shared.CustomerDto;
import org.mapstruct.ap.test.injectionstrategy.shared.CustomerEntity;
/**
* @author Kevin Grüneberg
*/
-@Mapper( componentModel = "jsr330",
+@Mapper( componentModel = MappingConstants.ComponentModel.JSR330,
uses = GenderJsr330ConstructorMapper.class,
injectionStrategy = InjectionStrategy.CONSTRUCTOR )
public interface CustomerJsr330ConstructorMapper {
diff --git a/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/jsr330/field/CustomerJsr330FieldMapper.java b/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/jsr330/field/CustomerJsr330FieldMapper.java
index 5c53a91c0..a9e02280a 100644
--- a/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/jsr330/field/CustomerJsr330FieldMapper.java
+++ b/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/jsr330/field/CustomerJsr330FieldMapper.java
@@ -7,13 +7,15 @@ package org.mapstruct.ap.test.injectionstrategy.jsr330.field;
import org.mapstruct.InjectionStrategy;
import org.mapstruct.Mapper;
+import org.mapstruct.MappingConstants;
import org.mapstruct.ap.test.injectionstrategy.shared.CustomerDto;
import org.mapstruct.ap.test.injectionstrategy.shared.CustomerEntity;
/**
* @author Kevin Grüneberg
*/
-@Mapper(componentModel = "jsr330", uses = GenderJsr330FieldMapper.class, injectionStrategy = InjectionStrategy.FIELD)
+@Mapper(componentModel = MappingConstants.ComponentModel.JSR330, uses = GenderJsr330FieldMapper.class,
+ injectionStrategy = InjectionStrategy.FIELD)
public interface CustomerJsr330FieldMapper {
CustomerDto asTarget(CustomerEntity customerEntity);
diff --git a/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/jsr330/field/FieldJsr330Config.java b/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/jsr330/field/FieldJsr330Config.java
index 33b5bbe8d..ba3938ae4 100644
--- a/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/jsr330/field/FieldJsr330Config.java
+++ b/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/jsr330/field/FieldJsr330Config.java
@@ -7,10 +7,11 @@ package org.mapstruct.ap.test.injectionstrategy.jsr330.field;
import org.mapstruct.InjectionStrategy;
import org.mapstruct.MapperConfig;
+import org.mapstruct.MappingConstants;
/**
* @author Filip Hrisafov
*/
-@MapperConfig(componentModel = "jsr330", injectionStrategy = InjectionStrategy.FIELD)
+@MapperConfig(componentModel = MappingConstants.ComponentModel.JSR330, injectionStrategy = InjectionStrategy.FIELD)
public interface FieldJsr330Config {
}
diff --git a/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/spring/_default/CustomerSpringDefaultMapper.java b/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/spring/_default/CustomerSpringDefaultMapper.java
index 34b06fc78..c7c2243d5 100644
--- a/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/spring/_default/CustomerSpringDefaultMapper.java
+++ b/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/spring/_default/CustomerSpringDefaultMapper.java
@@ -6,13 +6,14 @@
package org.mapstruct.ap.test.injectionstrategy.spring._default;
import org.mapstruct.Mapper;
+import org.mapstruct.MappingConstants;
import org.mapstruct.ap.test.injectionstrategy.shared.CustomerDto;
import org.mapstruct.ap.test.injectionstrategy.shared.CustomerEntity;
/**
* @author Filip Hrisafov
*/
-@Mapper(componentModel = "spring", uses = GenderSpringDefaultMapper.class )
+@Mapper(componentModel = MappingConstants.ComponentModel.SPRING, uses = GenderSpringDefaultMapper.class )
public interface CustomerSpringDefaultMapper {
CustomerDto asTarget(CustomerEntity customerEntity);
diff --git a/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/spring/_default/GenderSpringDefaultMapper.java b/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/spring/_default/GenderSpringDefaultMapper.java
index 106b93519..e49a82099 100644
--- a/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/spring/_default/GenderSpringDefaultMapper.java
+++ b/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/spring/_default/GenderSpringDefaultMapper.java
@@ -6,6 +6,7 @@
package org.mapstruct.ap.test.injectionstrategy.spring._default;
import org.mapstruct.Mapper;
+import org.mapstruct.MappingConstants;
import org.mapstruct.ValueMapping;
import org.mapstruct.ValueMappings;
import org.mapstruct.ap.test.injectionstrategy.shared.Gender;
@@ -14,7 +15,7 @@ import org.mapstruct.ap.test.injectionstrategy.shared.GenderDto;
/**
* @author Filip Hrisafov
*/
-@Mapper(componentModel = "spring")
+@Mapper(componentModel = MappingConstants.ComponentModel.SPRING)
public interface GenderSpringDefaultMapper {
@ValueMappings({
diff --git a/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/spring/compileoptionconstructor/CustomerRecordSpringCompileOptionConstructorMapper.java b/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/spring/compileoptionconstructor/CustomerRecordSpringCompileOptionConstructorMapper.java
index d7debfb96..f411ba506 100644
--- a/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/spring/compileoptionconstructor/CustomerRecordSpringCompileOptionConstructorMapper.java
+++ b/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/spring/compileoptionconstructor/CustomerRecordSpringCompileOptionConstructorMapper.java
@@ -6,13 +6,14 @@
package org.mapstruct.ap.test.injectionstrategy.spring.compileoptionconstructor;
import org.mapstruct.Mapper;
+import org.mapstruct.MappingConstants;
import org.mapstruct.ap.test.injectionstrategy.shared.CustomerRecordDto;
import org.mapstruct.ap.test.injectionstrategy.shared.CustomerRecordEntity;
/**
* @author Andrei Arlou
*/
-@Mapper(componentModel = "spring",
+@Mapper(componentModel = MappingConstants.ComponentModel.SPRING,
uses = { CustomerSpringCompileOptionConstructorMapper.class, GenderSpringCompileOptionConstructorMapper.class },
disableSubMappingMethodsGeneration = true)
public interface CustomerRecordSpringCompileOptionConstructorMapper {
diff --git a/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/spring/compileoptionconstructor/CustomerSpringCompileOptionConstructorMapper.java b/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/spring/compileoptionconstructor/CustomerSpringCompileOptionConstructorMapper.java
index db11c1b7a..47060104f 100644
--- a/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/spring/compileoptionconstructor/CustomerSpringCompileOptionConstructorMapper.java
+++ b/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/spring/compileoptionconstructor/CustomerSpringCompileOptionConstructorMapper.java
@@ -7,13 +7,14 @@ package org.mapstruct.ap.test.injectionstrategy.spring.compileoptionconstructor;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
+import org.mapstruct.MappingConstants;
import org.mapstruct.ap.test.injectionstrategy.shared.CustomerDto;
import org.mapstruct.ap.test.injectionstrategy.shared.CustomerEntity;
/**
* @author Andrei Arlou
*/
-@Mapper( componentModel = "spring",
+@Mapper( componentModel = MappingConstants.ComponentModel.SPRING,
uses = GenderSpringCompileOptionConstructorMapper.class)
public interface CustomerSpringCompileOptionConstructorMapper {
diff --git a/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/spring/compileoptionconstructor/GenderSpringCompileOptionConstructorMapper.java b/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/spring/compileoptionconstructor/GenderSpringCompileOptionConstructorMapper.java
index c909f1dc5..096fe91b9 100644
--- a/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/spring/compileoptionconstructor/GenderSpringCompileOptionConstructorMapper.java
+++ b/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/spring/compileoptionconstructor/GenderSpringCompileOptionConstructorMapper.java
@@ -6,6 +6,7 @@
package org.mapstruct.ap.test.injectionstrategy.spring.compileoptionconstructor;
import org.mapstruct.Mapper;
+import org.mapstruct.MappingConstants;
import org.mapstruct.ValueMapping;
import org.mapstruct.ValueMappings;
import org.mapstruct.ap.test.injectionstrategy.shared.Gender;
@@ -14,7 +15,7 @@ import org.mapstruct.ap.test.injectionstrategy.shared.GenderDto;
/**
* @author Andrei Arlou
*/
-@Mapper(componentModel = "spring")
+@Mapper(componentModel = MappingConstants.ComponentModel.SPRING)
public interface GenderSpringCompileOptionConstructorMapper {
@ValueMappings({
diff --git a/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/spring/constructor/ConstructorSpringConfig.java b/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/spring/constructor/ConstructorSpringConfig.java
index f4b46e35c..0bb89895c 100644
--- a/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/spring/constructor/ConstructorSpringConfig.java
+++ b/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/spring/constructor/ConstructorSpringConfig.java
@@ -7,10 +7,12 @@ package org.mapstruct.ap.test.injectionstrategy.spring.constructor;
import org.mapstruct.InjectionStrategy;
import org.mapstruct.MapperConfig;
+import org.mapstruct.MappingConstants;
/**
* @author Filip Hrisafov
*/
-@MapperConfig(componentModel = "spring", injectionStrategy = InjectionStrategy.CONSTRUCTOR)
+@MapperConfig(componentModel = MappingConstants.ComponentModel.SPRING,
+ injectionStrategy = InjectionStrategy.CONSTRUCTOR)
public interface ConstructorSpringConfig {
}
diff --git a/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/spring/constructor/CustomerRecordSpringConstructorMapper.java b/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/spring/constructor/CustomerRecordSpringConstructorMapper.java
index a7f9e8a8b..c2a586297 100644
--- a/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/spring/constructor/CustomerRecordSpringConstructorMapper.java
+++ b/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/spring/constructor/CustomerRecordSpringConstructorMapper.java
@@ -7,13 +7,14 @@ package org.mapstruct.ap.test.injectionstrategy.spring.constructor;
import org.mapstruct.InjectionStrategy;
import org.mapstruct.Mapper;
+import org.mapstruct.MappingConstants;
import org.mapstruct.ap.test.injectionstrategy.shared.CustomerRecordDto;
import org.mapstruct.ap.test.injectionstrategy.shared.CustomerRecordEntity;
/**
* @author Kevin Grüneberg
*/
-@Mapper(componentModel = "spring",
+@Mapper(componentModel = MappingConstants.ComponentModel.SPRING,
uses = { CustomerSpringConstructorMapper.class, GenderSpringConstructorMapper.class },
injectionStrategy = InjectionStrategy.CONSTRUCTOR,
disableSubMappingMethodsGeneration = true)
diff --git a/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/spring/constructor/CustomerSpringConstructorMapper.java b/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/spring/constructor/CustomerSpringConstructorMapper.java
index 9a9ab0119..4ea869ec5 100644
--- a/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/spring/constructor/CustomerSpringConstructorMapper.java
+++ b/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/spring/constructor/CustomerSpringConstructorMapper.java
@@ -8,13 +8,14 @@ package org.mapstruct.ap.test.injectionstrategy.spring.constructor;
import org.mapstruct.InjectionStrategy;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
+import org.mapstruct.MappingConstants;
import org.mapstruct.ap.test.injectionstrategy.shared.CustomerDto;
import org.mapstruct.ap.test.injectionstrategy.shared.CustomerEntity;
/**
* @author Kevin Grüneberg
*/
-@Mapper( componentModel = "spring",
+@Mapper( componentModel = MappingConstants.ComponentModel.SPRING,
uses = GenderSpringConstructorMapper.class,
injectionStrategy = InjectionStrategy.CONSTRUCTOR )
public interface CustomerSpringConstructorMapper {
diff --git a/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/spring/field/CustomerSpringFieldMapper.java b/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/spring/field/CustomerSpringFieldMapper.java
index 449cc5e43..fb8a316c5 100644
--- a/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/spring/field/CustomerSpringFieldMapper.java
+++ b/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/spring/field/CustomerSpringFieldMapper.java
@@ -7,13 +7,15 @@ package org.mapstruct.ap.test.injectionstrategy.spring.field;
import org.mapstruct.InjectionStrategy;
import org.mapstruct.Mapper;
+import org.mapstruct.MappingConstants;
import org.mapstruct.ap.test.injectionstrategy.shared.CustomerDto;
import org.mapstruct.ap.test.injectionstrategy.shared.CustomerEntity;
/**
* @author Kevin Grüneberg
*/
-@Mapper(componentModel = "spring", uses = GenderSpringFieldMapper.class, injectionStrategy = InjectionStrategy.FIELD)
+@Mapper(componentModel = MappingConstants.ComponentModel.SPRING, uses = GenderSpringFieldMapper.class,
+ injectionStrategy = InjectionStrategy.FIELD)
public interface CustomerSpringFieldMapper {
CustomerDto asTarget(CustomerEntity customerEntity);
diff --git a/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/spring/field/FieldSpringConfig.java b/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/spring/field/FieldSpringConfig.java
index d44a54c93..c9e3c3f0f 100644
--- a/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/spring/field/FieldSpringConfig.java
+++ b/processor/src/test/java/org/mapstruct/ap/test/injectionstrategy/spring/field/FieldSpringConfig.java
@@ -7,10 +7,11 @@ package org.mapstruct.ap.test.injectionstrategy.spring.field;
import org.mapstruct.InjectionStrategy;
import org.mapstruct.MapperConfig;
+import org.mapstruct.MappingConstants;
/**
* @author Filip Hrisafov
*/
-@MapperConfig(componentModel = "spring", injectionStrategy = InjectionStrategy.FIELD)
+@MapperConfig(componentModel = MappingConstants.ComponentModel.SPRING, injectionStrategy = InjectionStrategy.FIELD)
public interface FieldSpringConfig {
}
diff --git a/processor/src/test/java/org/mapstruct/ap/test/references/samename/Jsr330SourceTargetMapper.java b/processor/src/test/java/org/mapstruct/ap/test/references/samename/Jsr330SourceTargetMapper.java
index 6d613b0f9..f63b49eef 100644
--- a/processor/src/test/java/org/mapstruct/ap/test/references/samename/Jsr330SourceTargetMapper.java
+++ b/processor/src/test/java/org/mapstruct/ap/test/references/samename/Jsr330SourceTargetMapper.java
@@ -6,6 +6,7 @@
package org.mapstruct.ap.test.references.samename;
import org.mapstruct.Mapper;
+import org.mapstruct.MappingConstants;
import org.mapstruct.ap.test.references.samename.a.CustomMapper;
import org.mapstruct.ap.test.references.samename.model.Source;
import org.mapstruct.ap.test.references.samename.model.Target;
@@ -15,7 +16,7 @@ import org.mapstruct.factory.Mappers;
* @author Gunnar Morling
*/
@Mapper(
- componentModel = "jsr330",
+ componentModel = MappingConstants.ComponentModel.JSR330,
uses = {
CustomMapper.class,
org.mapstruct.ap.test.references.samename.b.CustomMapper.class