diff --git a/core/src/main/java/org/mapstruct/Mapper.java b/core/src/main/java/org/mapstruct/Mapper.java
index 11266feab..030e19006 100644
--- a/core/src/main/java/org/mapstruct/Mapper.java
+++ b/core/src/main/java/org/mapstruct/Mapper.java
@@ -44,11 +44,12 @@ public @interface Mapper {
/**
* How unmapped properties of the target type of a mapping should be
- * reported.
+ * reported. The method overrides an unmappedTargetPolicy set in a central
+ * configuration set by {@link #mapperConfig() }
*
* @return The reporting policy for unmapped target properties.
*/
- ReportingPolicy unmappedTargetPolicy() default ReportingPolicy.WARN;
+ ReportingPolicy unmappedTargetPolicy() default ReportingPolicy.DEFAULT;
/**
* Specifies the component model to which the generated mapper should
@@ -66,8 +67,18 @@ public @interface Mapper {
* {@code jsr330}: the generated mapper is annotated with {@code @Named} and
* can be retrieved via {@code @Inject}
*
- *
- * @return The component model for the generated mapper.
+ * The method overrides an unmappedTargetPolicy set in a central configuration set
+ * by {@link #mapperConfig() }
+
+* @return The component model for the generated mapper.
*/
String componentModel() default "default";
+
+ /**
+ * Central mapper configuration, carrying the {@link MapperConfig} annotation
+ *
+ * @return a centralized class with {@link MapperConfig} annotation.
+ */
+ Class> mapperConfig() default void.class;
+
}
diff --git a/core/src/main/java/org/mapstruct/MapperConfig.java b/core/src/main/java/org/mapstruct/MapperConfig.java
new file mode 100644
index 000000000..66c2d32e0
--- /dev/null
+++ b/core/src/main/java/org/mapstruct/MapperConfig.java
@@ -0,0 +1,76 @@
+/**
+ * Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/)
+ * and/or other contributors as indicated by the @authors tag. See the
+ * copyright.txt file in the distribution for a full listing of all
+ * contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.mapstruct;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import org.mapstruct.factory.Mappers;
+
+/**
+ * Marks an interface as mapper interface and activates the generation of a
+ * mapper implementation for that interface.
+ *
+ * The {@link #unmappedTargetPolicy() } and {@link #componentModel() } an be overruled by a specific {@link Mapper}
+ * annotation. {@link #uses() } will be used in addition to what is specified in the {@link Mapper} annotation.
+ *
+ * @author Sjaak Derksen
+ */
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.SOURCE)
+public @interface MapperConfig {
+
+ /**
+ * The mapper types used by this mapper.
+ *
+ * @return The mapper types used by this mapper.
+ */
+ Class>[] uses() default { };
+
+ /**
+ * How unmapped properties of the target type of a mapping should be
+ * reported.
+ *
+ * @return The reporting policy for unmapped target properties.
+ */
+ ReportingPolicy unmappedTargetPolicy() default ReportingPolicy.DEFAULT;
+
+ /**
+ * Specifies the component model to which the generated mapper should
+ * adhere. Supported values are
+ *
+ * - {@code default}: the mapper uses no component model, instances are
+ * typically retrieved via {@link Mappers#getMapper(Class)}
+ * -
+ * {@code cdi}: the generated mapper is an application-scoped CDI bean and
+ * can be retrieved via {@code @Inject}
+ * -
+ * {@code spring}: the generated mapper is a Spring bean and
+ * can be retrieved via {@code @Autowired}
+ * -
+ * {@code jsr330}: the generated mapper is annotated with {@code @Named} and
+ * can be retrieved via {@code @Inject}
+ *
+ *
+ * @return The component model for the generated mapper.
+ */
+ String componentModel() default "default";
+}
diff --git a/core/src/main/java/org/mapstruct/ReportingPolicy.java b/core/src/main/java/org/mapstruct/ReportingPolicy.java
index a9a8b96be..cbba67c1b 100644
--- a/core/src/main/java/org/mapstruct/ReportingPolicy.java
+++ b/core/src/main/java/org/mapstruct/ReportingPolicy.java
@@ -42,5 +42,12 @@ public enum ReportingPolicy {
* A report with {@link Kind#ERROR} will be created for the given issue,
* causing the compilation to fail.
*/
- ERROR;
+ ERROR,
+
+ /**
+ * A report with {@link Kind#WARNING} will be created for the given issue.
+ *
+ * This value is the default value and used to distinguish it from a user set WARNING level.
+ */
+ DEFAULT;
}
diff --git a/processor/src/main/java/org/mapstruct/ap/option/ReportingPolicy.java b/processor/src/main/java/org/mapstruct/ap/option/ReportingPolicy.java
index dadfa6200..92d688c5b 100644
--- a/processor/src/main/java/org/mapstruct/ap/option/ReportingPolicy.java
+++ b/processor/src/main/java/org/mapstruct/ap/option/ReportingPolicy.java
@@ -29,7 +29,10 @@ import javax.tools.Diagnostic.Kind;
*/
public enum ReportingPolicy {
- IGNORE( null, false, false ), WARN( Kind.WARNING, true, false ), ERROR( Kind.ERROR, true, true );
+ IGNORE( null, false, false ),
+ WARN( Kind.WARNING, true, false ),
+ ERROR( Kind.ERROR, true, true ),
+ DEFAULT( Kind.WARNING, true, false );
private final Diagnostic.Kind diagnosticKind;
private final boolean requiresReport;
diff --git a/processor/src/main/java/org/mapstruct/ap/prism/PrismGenerator.java b/processor/src/main/java/org/mapstruct/ap/prism/PrismGenerator.java
index 27864e56e..0dbc9ef46 100644
--- a/processor/src/main/java/org/mapstruct/ap/prism/PrismGenerator.java
+++ b/processor/src/main/java/org/mapstruct/ap/prism/PrismGenerator.java
@@ -26,6 +26,7 @@ import org.mapstruct.DecoratedWith;
import org.mapstruct.IterableMapping;
import org.mapstruct.MapMapping;
import org.mapstruct.Mapper;
+import org.mapstruct.MapperConfig;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;
import org.mapstruct.Mappings;
@@ -45,6 +46,7 @@ import org.mapstruct.TargetType;
@GeneratePrism(value = TargetType.class, publicAccess = true),
@GeneratePrism(value = MappingTarget.class, publicAccess = true),
@GeneratePrism(value = DecoratedWith.class, publicAccess = true),
+ @GeneratePrism(value = MapperConfig.class, publicAccess = true),
// external types
@GeneratePrism(value = XmlElementDecl.class, publicAccess = true)
diff --git a/processor/src/main/java/org/mapstruct/ap/processor/AnnotationBasedComponentModelProcessor.java b/processor/src/main/java/org/mapstruct/ap/processor/AnnotationBasedComponentModelProcessor.java
index 858c4892b..b62493dfa 100644
--- a/processor/src/main/java/org/mapstruct/ap/processor/AnnotationBasedComponentModelProcessor.java
+++ b/processor/src/main/java/org/mapstruct/ap/processor/AnnotationBasedComponentModelProcessor.java
@@ -27,7 +27,7 @@ import org.mapstruct.ap.model.Mapper;
import org.mapstruct.ap.model.MapperReference;
import org.mapstruct.ap.model.common.TypeFactory;
import org.mapstruct.ap.option.OptionsHelper;
-import org.mapstruct.ap.prism.MapperPrism;
+import org.mapstruct.ap.util.MapperSettings;
/**
* An {@link ModelElementProcessor} which converts the given {@link Mapper}
@@ -45,7 +45,7 @@ public abstract class AnnotationBasedComponentModelProcessor implements ModelEle
public Mapper process(ProcessorContext context, TypeElement mapperTypeElement, Mapper mapper) {
this.typeFactory = context.getTypeFactory();
- String componentModel = MapperPrism.getInstanceOn( mapperTypeElement ).componentModel();
+ String componentModel = MapperSettings.getInstanceOn( mapperTypeElement ).componentModel();
String effectiveComponentModel = OptionsHelper.getEffectiveComponentModel(
context.getOptions(),
componentModel
diff --git a/processor/src/main/java/org/mapstruct/ap/processor/MapperCreationProcessor.java b/processor/src/main/java/org/mapstruct/ap/processor/MapperCreationProcessor.java
index d7f552cb7..e3d96b831 100644
--- a/processor/src/main/java/org/mapstruct/ap/processor/MapperCreationProcessor.java
+++ b/processor/src/main/java/org/mapstruct/ap/processor/MapperCreationProcessor.java
@@ -71,6 +71,7 @@ import org.mapstruct.ap.prism.DecoratedWithPrism;
import org.mapstruct.ap.prism.MapperPrism;
import org.mapstruct.ap.util.Executables;
import org.mapstruct.ap.util.Filters;
+import org.mapstruct.ap.util.MapperSettings;
import org.mapstruct.ap.util.Strings;
/**
@@ -151,9 +152,9 @@ public class MapperCreationProcessor implements ModelElementProcessor mapperReferences = new LinkedList();
List variableNames = new LinkedList();
- MapperPrism mapperPrism = MapperPrism.getInstanceOn( element );
+ MapperSettings mapperPrism = MapperSettings.getInstanceOn( element );
for ( TypeMirror usedMapper : mapperPrism.uses() ) {
DefaultMapperReference mapperReference = DefaultMapperReference.getInstance(
diff --git a/processor/src/main/java/org/mapstruct/ap/processor/MethodRetrievalProcessor.java b/processor/src/main/java/org/mapstruct/ap/processor/MethodRetrievalProcessor.java
index ac5a76b6b..3a5730637 100644
--- a/processor/src/main/java/org/mapstruct/ap/processor/MethodRetrievalProcessor.java
+++ b/processor/src/main/java/org/mapstruct/ap/processor/MethodRetrievalProcessor.java
@@ -44,10 +44,10 @@ import org.mapstruct.ap.model.source.Mapping;
import org.mapstruct.ap.model.source.SourceMethod;
import org.mapstruct.ap.prism.IterableMappingPrism;
import org.mapstruct.ap.prism.MapMappingPrism;
-import org.mapstruct.ap.prism.MapperPrism;
import org.mapstruct.ap.prism.MappingPrism;
import org.mapstruct.ap.prism.MappingsPrism;
import org.mapstruct.ap.util.AnnotationProcessingException;
+import org.mapstruct.ap.util.MapperSettings;
/**
* A {@link ModelElementProcessor} which retrieves a list of {@link SourceMethod}s
@@ -98,14 +98,14 @@ public class MethodRetrievalProcessor implements ModelElementProcessor uses() {
+ Set uses = new HashSet( mapperPrism.uses() );
+ if ( mapperConfigPrism != null ) {
+ uses.addAll( mapperConfigPrism.uses() );
+ }
+ return new ArrayList( uses );
+ }
+
+ public String unmappedTargetPolicy() {
+ if ( !ReportingPolicy.valueOf( mapperPrism.unmappedTargetPolicy() ).equals( ReportingPolicy.DEFAULT ) ) {
+ // it is not the default configuration
+ return mapperPrism.unmappedTargetPolicy();
+ }
+ else if ( mapperConfigPrism != null &&
+ !ReportingPolicy.valueOf( mapperConfigPrism.unmappedTargetPolicy())
+ .equals( ReportingPolicy.DEFAULT ) ) {
+ return mapperConfigPrism.unmappedTargetPolicy();
+ }
+ else {
+ return ReportingPolicy.WARN.name();
+ }
+ }
+
+ public String componentModel() {
+ if ( !mapperPrism.componentModel().equals( "default" ) ) {
+ return mapperPrism.componentModel();
+ }
+ else if ( mapperConfigPrism != null ) {
+ return mapperConfigPrism.componentModel();
+ }
+ else {
+ return "default";
+ }
+ }
+
+ public boolean isValid() {
+ return mapperPrism.isValid;
+ }
+
+ public boolean isSetUnmappedTargetPolicy() {
+ return mapperPrism.values.unmappedTargetPolicy() != null;
+ }
+
+ public AnnotationMirror getAnnotationMirror() {
+ return mapperPrism.mirror;
+ }
+}
diff --git a/processor/src/test/java/org/mapstruct/ap/test/mapperconfig/BarDto.java b/processor/src/test/java/org/mapstruct/ap/test/mapperconfig/BarDto.java
new file mode 100644
index 000000000..c7d1c69e4
--- /dev/null
+++ b/processor/src/test/java/org/mapstruct/ap/test/mapperconfig/BarDto.java
@@ -0,0 +1,27 @@
+/**
+ * Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/)
+ * and/or other contributors as indicated by the @authors tag. See the
+ * copyright.txt file in the distribution for a full listing of all
+ * contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.mapstruct.ap.test.mapperconfig;
+
+/**
+ *
+ * @author Sjaak Derksen
+ */
+public class BarDto {
+
+}
diff --git a/processor/src/test/java/org/mapstruct/ap/test/mapperconfig/BarEntity.java b/processor/src/test/java/org/mapstruct/ap/test/mapperconfig/BarEntity.java
new file mode 100644
index 000000000..ed88fccb5
--- /dev/null
+++ b/processor/src/test/java/org/mapstruct/ap/test/mapperconfig/BarEntity.java
@@ -0,0 +1,27 @@
+/**
+ * Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/)
+ * and/or other contributors as indicated by the @authors tag. See the
+ * copyright.txt file in the distribution for a full listing of all
+ * contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.mapstruct.ap.test.mapperconfig;
+
+/**
+ *
+ * @author Sjaak Derksen
+ */
+public class BarEntity {
+
+}
diff --git a/processor/src/test/java/org/mapstruct/ap/test/mapperconfig/CentralConfig.java b/processor/src/test/java/org/mapstruct/ap/test/mapperconfig/CentralConfig.java
new file mode 100644
index 000000000..4e3b8832e
--- /dev/null
+++ b/processor/src/test/java/org/mapstruct/ap/test/mapperconfig/CentralConfig.java
@@ -0,0 +1,31 @@
+/**
+ * Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/)
+ * and/or other contributors as indicated by the @authors tag. See the
+ * copyright.txt file in the distribution for a full listing of all
+ * contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.mapstruct.ap.test.mapperconfig;
+
+import org.mapstruct.MapperConfig;
+import org.mapstruct.ReportingPolicy;
+
+/**
+ *
+ * @author Sjaak Derksen
+ */
+@MapperConfig(uses = { CustomMapperViaMapperConfig.class }, unmappedTargetPolicy = ReportingPolicy.ERROR )
+public class CentralConfig {
+
+}
diff --git a/processor/src/test/java/org/mapstruct/ap/test/mapperconfig/ConfigTest.java b/processor/src/test/java/org/mapstruct/ap/test/mapperconfig/ConfigTest.java
new file mode 100644
index 000000000..08e17b612
--- /dev/null
+++ b/processor/src/test/java/org/mapstruct/ap/test/mapperconfig/ConfigTest.java
@@ -0,0 +1,86 @@
+/**
+ * Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/)
+ * and/or other contributors as indicated by the @authors tag. See the
+ * copyright.txt file in the distribution for a full listing of all
+ * contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.mapstruct.ap.test.mapperconfig;
+
+import static org.fest.assertions.Assertions.assertThat;
+import org.mapstruct.ap.testutil.IssueKey;
+import org.mapstruct.ap.testutil.MapperTestBase;
+import org.mapstruct.ap.testutil.WithClasses;
+import org.mapstruct.ap.testutil.compilation.annotation.CompilationResult;
+import org.mapstruct.ap.testutil.compilation.annotation.Diagnostic;
+import org.mapstruct.ap.testutil.compilation.annotation.ExpectedCompilationOutcome;
+import org.testng.annotations.Test;
+
+/**
+ *
+ * @author Sjaak Derksen
+ */
+@IssueKey( "102" )
+@WithClasses( {
+ Source.class,
+ Target.class,
+ FooDto.class,
+ FooEntity.class,
+ CentralConfig.class,
+ CustomMapperViaMapper.class,
+ CustomMapperViaMapperConfig.class,
+ SourceTargetMapper.class
+} )
+public class ConfigTest extends MapperTestBase {
+
+ @Test
+ @WithClasses( { Target.class, SourceTargetMapper.class } )
+ public void shouldUseCustomMapperViaMapperForFooToEntity() {
+
+ Target target = SourceTargetMapper.INSTANCE.toTarget( new Source( new FooDto() ) );
+ assertThat( target.getFoo() ).isNotNull();
+ assertThat( target.getFoo().getCreatedBy() ).isEqualTo( CustomMapperViaMapper.class.getSimpleName() );
+ }
+
+ @Test
+ @WithClasses( { Target.class, SourceTargetMapper.class } )
+ public void shouldUseCustomMapperViaMapperConfigForFooToDto() {
+
+ Source source = SourceTargetMapper.INSTANCE.toSource( new Target( new FooEntity() ) );
+ assertThat( source.getFoo() ).isNotNull();
+ assertThat( source.getFoo().getCreatedBy() ).isEqualTo( CustomMapperViaMapperConfig.class.getSimpleName() );
+ }
+
+ @Test
+ @WithClasses( { TargetNoFoo.class, SourceTargetMapperWarn.class } )
+ @ExpectedCompilationOutcome(value = CompilationResult.SUCCEEDED,
+ diagnostics = {
+ @Diagnostic(type = SourceTargetMapperWarn.class,
+ kind = javax.tools.Diagnostic.Kind.WARNING, line = 37,
+ messageRegExp = "Unmapped target property: \"noFoo\"")
+ })
+ public void shouldUseWARNViaMapper() {
+ }
+
+ @Test
+ @WithClasses( { TargetNoFoo.class, SourceTargetMapperError.class } )
+ @ExpectedCompilationOutcome(value = CompilationResult.FAILED,
+ diagnostics = {
+ @Diagnostic(type = SourceTargetMapperError.class,
+ kind = javax.tools.Diagnostic.Kind.ERROR, line = 33,
+ messageRegExp = "Unmapped target property: \"noFoo\"")
+ })
+ public void shouldUseERRORViaMapperConfig() {
+ }
+}
diff --git a/processor/src/test/java/org/mapstruct/ap/test/mapperconfig/CustomMapperViaMapper.java b/processor/src/test/java/org/mapstruct/ap/test/mapperconfig/CustomMapperViaMapper.java
new file mode 100644
index 000000000..c525fbfec
--- /dev/null
+++ b/processor/src/test/java/org/mapstruct/ap/test/mapperconfig/CustomMapperViaMapper.java
@@ -0,0 +1,30 @@
+/**
+ * Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/)
+ * and/or other contributors as indicated by the @authors tag. See the
+ * copyright.txt file in the distribution for a full listing of all
+ * contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.mapstruct.ap.test.mapperconfig;
+
+/**
+ *
+ * @author Sjaak Derksen
+ */
+public class CustomMapperViaMapper {
+
+ public FooEntity toFooEntity( FooDto dto ) {
+ return new FooEntity( this.getClass().getSimpleName() );
+ }
+}
diff --git a/processor/src/test/java/org/mapstruct/ap/test/mapperconfig/CustomMapperViaMapperConfig.java b/processor/src/test/java/org/mapstruct/ap/test/mapperconfig/CustomMapperViaMapperConfig.java
new file mode 100644
index 000000000..8f35a1ca8
--- /dev/null
+++ b/processor/src/test/java/org/mapstruct/ap/test/mapperconfig/CustomMapperViaMapperConfig.java
@@ -0,0 +1,30 @@
+/**
+ * Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/)
+ * and/or other contributors as indicated by the @authors tag. See the
+ * copyright.txt file in the distribution for a full listing of all
+ * contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.mapstruct.ap.test.mapperconfig;
+
+/**
+ *
+ * @author Sjaak Derksen
+ */
+public class CustomMapperViaMapperConfig {
+
+ public FooDto toFooDto(FooEntity foo) {
+ return new FooDto( this.getClass().getSimpleName() );
+ }
+}
diff --git a/processor/src/test/java/org/mapstruct/ap/test/mapperconfig/FooDto.java b/processor/src/test/java/org/mapstruct/ap/test/mapperconfig/FooDto.java
new file mode 100644
index 000000000..c34e62fc3
--- /dev/null
+++ b/processor/src/test/java/org/mapstruct/ap/test/mapperconfig/FooDto.java
@@ -0,0 +1,40 @@
+/**
+ * Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/)
+ * and/or other contributors as indicated by the @authors tag. See the
+ * copyright.txt file in the distribution for a full listing of all
+ * contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.mapstruct.ap.test.mapperconfig;
+
+/**
+ *
+ * @author Sjaak Derksen
+ */
+public class FooDto {
+
+ private String createdBy;
+
+ public FooDto() {
+ }
+
+ public FooDto( String createdBy ) {
+ this.createdBy = createdBy;
+ }
+
+ public String getCreatedBy() {
+ return createdBy;
+ }
+
+}
diff --git a/processor/src/test/java/org/mapstruct/ap/test/mapperconfig/FooEntity.java b/processor/src/test/java/org/mapstruct/ap/test/mapperconfig/FooEntity.java
new file mode 100644
index 000000000..2b35b0630
--- /dev/null
+++ b/processor/src/test/java/org/mapstruct/ap/test/mapperconfig/FooEntity.java
@@ -0,0 +1,40 @@
+/**
+ * Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/)
+ * and/or other contributors as indicated by the @authors tag. See the
+ * copyright.txt file in the distribution for a full listing of all
+ * contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.mapstruct.ap.test.mapperconfig;
+
+/**
+ *
+ * @author Sjaak Derksen
+ */
+public class FooEntity {
+
+ private String createdBy;
+
+ public FooEntity() {
+ }
+
+ public FooEntity( String createdBy ) {
+ this.createdBy = createdBy;
+ }
+
+ public String getCreatedBy() {
+ return createdBy;
+ }
+
+}
diff --git a/processor/src/test/java/org/mapstruct/ap/test/mapperconfig/Source.java b/processor/src/test/java/org/mapstruct/ap/test/mapperconfig/Source.java
new file mode 100644
index 000000000..610b953f5
--- /dev/null
+++ b/processor/src/test/java/org/mapstruct/ap/test/mapperconfig/Source.java
@@ -0,0 +1,44 @@
+/**
+ * Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/)
+ * and/or other contributors as indicated by the @authors tag. See the
+ * copyright.txt file in the distribution for a full listing of all
+ * contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.mapstruct.ap.test.mapperconfig;
+
+/**
+ *
+ * @author Sjaak Derksen
+ */
+public class Source {
+
+ private FooDto foo;
+
+ public Source( ) {
+ }
+
+ public Source( FooDto foo ) {
+ this.foo = foo;
+ }
+
+ public FooDto getFoo() {
+ return foo;
+ }
+
+ public void setFoo( FooDto foo ) {
+ this.foo = foo;
+ }
+
+}
diff --git a/processor/src/test/java/org/mapstruct/ap/test/mapperconfig/SourceTargetMapper.java b/processor/src/test/java/org/mapstruct/ap/test/mapperconfig/SourceTargetMapper.java
new file mode 100644
index 000000000..89084b6f2
--- /dev/null
+++ b/processor/src/test/java/org/mapstruct/ap/test/mapperconfig/SourceTargetMapper.java
@@ -0,0 +1,35 @@
+/**
+ * Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/)
+ * and/or other contributors as indicated by the @authors tag. See the
+ * copyright.txt file in the distribution for a full listing of all
+ * contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.mapstruct.ap.test.mapperconfig;
+
+import org.mapstruct.Mapper;
+import org.mapstruct.factory.Mappers;
+
+/**
+ *
+ * @author Sjaak Derksen
+ */
+@Mapper(uses = { CustomMapperViaMapper.class }, mapperConfig = CentralConfig.class )
+public interface SourceTargetMapper {
+
+ SourceTargetMapper INSTANCE = Mappers.getMapper( SourceTargetMapper.class );
+
+ Target toTarget( Source source );
+ Source toSource( Target target );
+}
diff --git a/processor/src/test/java/org/mapstruct/ap/test/mapperconfig/SourceTargetMapperError.java b/processor/src/test/java/org/mapstruct/ap/test/mapperconfig/SourceTargetMapperError.java
new file mode 100644
index 000000000..940408b67
--- /dev/null
+++ b/processor/src/test/java/org/mapstruct/ap/test/mapperconfig/SourceTargetMapperError.java
@@ -0,0 +1,34 @@
+/**
+ * Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/)
+ * and/or other contributors as indicated by the @authors tag. See the
+ * copyright.txt file in the distribution for a full listing of all
+ * contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.mapstruct.ap.test.mapperconfig;
+
+import org.mapstruct.Mapper;
+import org.mapstruct.factory.Mappers;
+
+/**
+ *
+ * @author Sjaak Derksen
+ */
+@Mapper(uses = { CustomMapperViaMapper.class }, mapperConfig = CentralConfig.class )
+public interface SourceTargetMapperError {
+
+ SourceTargetMapperError INSTANCE = Mappers.getMapper( SourceTargetMapperError.class );
+
+ TargetNoFoo toTarget( Source source );
+}
diff --git a/processor/src/test/java/org/mapstruct/ap/test/mapperconfig/SourceTargetMapperWarn.java b/processor/src/test/java/org/mapstruct/ap/test/mapperconfig/SourceTargetMapperWarn.java
new file mode 100644
index 000000000..7d2d42648
--- /dev/null
+++ b/processor/src/test/java/org/mapstruct/ap/test/mapperconfig/SourceTargetMapperWarn.java
@@ -0,0 +1,38 @@
+/**
+ * Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/)
+ * and/or other contributors as indicated by the @authors tag. See the
+ * copyright.txt file in the distribution for a full listing of all
+ * contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.mapstruct.ap.test.mapperconfig;
+
+import org.mapstruct.Mapper;
+import org.mapstruct.ReportingPolicy;
+import org.mapstruct.factory.Mappers;
+
+/**
+ *
+ * @author Sjaak Derksen
+ */
+@Mapper(uses = { CustomMapperViaMapper.class },
+ mapperConfig = CentralConfig.class,
+ unmappedTargetPolicy = ReportingPolicy.WARN
+)
+public interface SourceTargetMapperWarn {
+
+ SourceTargetMapperWarn INSTANCE = Mappers.getMapper( SourceTargetMapperWarn.class );
+
+ TargetNoFoo toTarget( Source source );
+}
diff --git a/processor/src/test/java/org/mapstruct/ap/test/mapperconfig/Target.java b/processor/src/test/java/org/mapstruct/ap/test/mapperconfig/Target.java
new file mode 100644
index 000000000..3fc04125f
--- /dev/null
+++ b/processor/src/test/java/org/mapstruct/ap/test/mapperconfig/Target.java
@@ -0,0 +1,44 @@
+/**
+ * Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/)
+ * and/or other contributors as indicated by the @authors tag. See the
+ * copyright.txt file in the distribution for a full listing of all
+ * contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.mapstruct.ap.test.mapperconfig;
+
+/**
+ *
+ * @author Sjaak Derksen
+ */
+public class Target {
+
+ private FooEntity foo;
+
+ public Target() {
+ }
+
+ public Target( FooEntity foo ) {
+ this.foo = foo;
+ }
+
+ public FooEntity getFoo() {
+ return foo;
+ }
+
+ public void setFoo( FooEntity foo ) {
+ this.foo = foo;
+ }
+
+}
diff --git a/processor/src/test/java/org/mapstruct/ap/test/mapperconfig/TargetNoFoo.java b/processor/src/test/java/org/mapstruct/ap/test/mapperconfig/TargetNoFoo.java
new file mode 100644
index 000000000..d964397a1
--- /dev/null
+++ b/processor/src/test/java/org/mapstruct/ap/test/mapperconfig/TargetNoFoo.java
@@ -0,0 +1,37 @@
+/**
+ * Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/)
+ * and/or other contributors as indicated by the @authors tag. See the
+ * copyright.txt file in the distribution for a full listing of all
+ * contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.mapstruct.ap.test.mapperconfig;
+
+/**
+ *
+ * @author Sjaak Derksen
+ */
+public class TargetNoFoo {
+
+ private FooEntity noFoo;
+
+ public FooEntity getNoFoo() {
+ return noFoo;
+ }
+
+ public void setNoFoo( FooEntity noFoo ) {
+ this.noFoo = noFoo;
+ }
+
+}