From 4d408d55605fa517f7ff90d3c800f2a02b57eacf Mon Sep 17 00:00:00 2001 From: Gunnar Morling Date: Tue, 14 Oct 2014 22:03:07 +0200 Subject: [PATCH] #252 Formatting --- .../ap/processor/MapperCreationProcessor.java | 114 ++++++++------- .../InheritInverseConfigurationTest.java | 135 +++++++++--------- .../org/mapstruct/ap/test/reverse/Source.java | 9 +- .../ap/test/reverse/SourceTargetMapper.java | 38 +++-- .../reverse/SourceTargetMapperAmbiguous1.java | 38 +++-- .../reverse/SourceTargetMapperAmbiguous2.java | 38 +++-- .../reverse/SourceTargetMapperAmbiguous3.java | 38 +++-- ...ourceTargetMapperErroneouslyAnnotated.java | 40 +++--- .../SourceTargetMapperNonMatchingName.java | 26 ++-- .../org/mapstruct/ap/test/reverse/Target.java | 7 +- 10 files changed, 243 insertions(+), 240 deletions(-) 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 612e49a2d..a9db5c2b6 100644 --- a/processor/src/main/java/org/mapstruct/ap/processor/MapperCreationProcessor.java +++ b/processor/src/main/java/org/mapstruct/ap/processor/MapperCreationProcessor.java @@ -25,7 +25,6 @@ import java.util.List; import java.util.Map; import java.util.SortedSet; import java.util.TreeSet; - import javax.annotation.processing.Messager; import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.TypeElement; @@ -312,7 +311,7 @@ public class MapperCreationProcessor implements ModelElementProcessor> newMappings = new HashMap>(); if ( reverseMappingMethod != null && !reverseMappingMethod.getMappings().isEmpty() ) { // define all the base mappings based on its forward counterpart @@ -406,12 +405,12 @@ public class MapperCreationProcessor implements ModelElementProcessor rawMethods, SourceMethod method) { - SourceMethod result = null; + InheritInverseConfigurationPrism reversePrism = InheritInverseConfigurationPrism.getInstanceOn( + method.getExecutable() + ); - InheritInverseConfigurationPrism reversePrism = InheritInverseConfigurationPrism.getInstanceOn( method.getExecutable() ); if ( reversePrism != null ) { // method is configured as being reverse method, collect candidates @@ -445,7 +444,7 @@ public class MapperCreationProcessor implements ModelElementProcessor 1 ) { @@ -458,74 +457,93 @@ public class MapperCreationProcessor implements ModelElementProcessor candidates, SourceMethod method, - InheritInverseConfigurationPrism reversePrism ) { + private void reportErrorWhenAmbigousReverseMapping(List candidates, SourceMethod method, + InheritInverseConfigurationPrism reversePrism) { List candidateNames = new ArrayList(); - for (SourceMethod candidate : candidates ) { + for ( SourceMethod candidate : candidates ) { candidateNames.add( candidate.getName() ); } String name = reversePrism.name(); if ( name.isEmpty() ) { - messager.printMessage( Diagnostic.Kind.ERROR, - String.format( "Several matching inverse methods exist: %s(). Specify a name explicitly.", - Strings.join( candidateNames, "(), " ) - ), - method.getExecutable(), - reversePrism.mirror ); + messager.printMessage( + Diagnostic.Kind.ERROR, + String.format( + "Several matching inverse methods exist: %s(). Specify a name explicitly.", + Strings.join( candidateNames, "(), " ) + ), + method.getExecutable(), + reversePrism.mirror + ); } else { - messager.printMessage( Diagnostic.Kind.ERROR, - String.format( "None of the candidates %s() matches given name: \"%s\".", - Strings.join( candidateNames, "(), " ), name - ), - method.getExecutable(), - reversePrism.mirror ); + messager.printMessage( + Diagnostic.Kind.ERROR, + String.format( + "None of the candidates %s() matches given name: \"%s\".", + Strings.join( candidateNames, "(), " ), name + ), + method.getExecutable(), + reversePrism.mirror + ); } } private void reportErrorWhenSeveralNamesMatch(List candidates, SourceMethod method, - InheritInverseConfigurationPrism reversePrism ) { + InheritInverseConfigurationPrism reversePrism) { - messager.printMessage( Diagnostic.Kind.ERROR, - String.format( "Given name \"%s\" matches several candidate methods: %s().", - reversePrism.name(), Strings.join( candidates, "(), " ) - ), - method.getExecutable(), - reversePrism.mirror ); + messager.printMessage( + Diagnostic.Kind.ERROR, + String.format( + "Given name \"%s\" matches several candidate methods: %s().", + reversePrism.name(), Strings.join( candidates, "(), " ) + ), + method.getExecutable(), + reversePrism.mirror + ); } private void reportErrorWhenNonMatchingName(SourceMethod onlyCandidate, SourceMethod method, - InheritInverseConfigurationPrism reversePrism ) { + InheritInverseConfigurationPrism reversePrism) { - messager.printMessage( Diagnostic.Kind.ERROR, - String.format( "Given name \"%s\" does not match the only candidate. Did you mean: \"%s\".", - reversePrism.name(), onlyCandidate.getName() - ), - method.getExecutable(), - reversePrism.mirror ); + messager.printMessage( + Diagnostic.Kind.ERROR, + String.format( + "Given name \"%s\" does not match the only candidate. Did you mean: \"%s\".", + reversePrism.name(), onlyCandidate.getName() + ), + method.getExecutable(), + reversePrism.mirror + ); } } diff --git a/processor/src/test/java/org/mapstruct/ap/test/reverse/InheritInverseConfigurationTest.java b/processor/src/test/java/org/mapstruct/ap/test/reverse/InheritInverseConfigurationTest.java index 67d721368..9b5b75b00 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/reverse/InheritInverseConfigurationTest.java +++ b/processor/src/test/java/org/mapstruct/ap/test/reverse/InheritInverseConfigurationTest.java @@ -18,8 +18,6 @@ */ package org.mapstruct.ap.test.reverse; -import static org.fest.assertions.Assertions.assertThat; - import javax.tools.Diagnostic.Kind; import org.junit.Test; @@ -31,17 +29,18 @@ import org.mapstruct.ap.testutil.compilation.annotation.Diagnostic; import org.mapstruct.ap.testutil.compilation.annotation.ExpectedCompilationOutcome; import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner; +import static org.fest.assertions.Assertions.assertThat; + /** * @author Sjaak Derksen - * */ -@IssueKey( "252" ) -@WithClasses( { Source.class, Target.class } ) -@RunWith( AnnotationProcessorTestRunner.class ) +@IssueKey("252") +@WithClasses({ Source.class, Target.class }) +@RunWith(AnnotationProcessorTestRunner.class) public class InheritInverseConfigurationTest { @Test - @WithClasses( { SourceTargetMapper.class } ) + @WithClasses({ SourceTargetMapper.class }) public void shouldInheritInverseConfigurationMultipleCandidates() { Source source = new Source(); @@ -64,92 +63,92 @@ public class InheritInverseConfigurationTest { } @Test - @WithClasses( { SourceTargetMapperAmbiguous1.class } ) + @WithClasses({ SourceTargetMapperAmbiguous1.class }) @ExpectedCompilationOutcome( - value = CompilationResult.FAILED, - diagnostics = { - @Diagnostic( type = SourceTargetMapperAmbiguous1.class, - kind = Kind.ERROR, - line = 51, - messageRegExp = "Several matching inverse methods exist: forward\\(\\), " - + "forwardNotToReverse\\(\\). Specify a name explicitly." ), - @Diagnostic( type = SourceTargetMapperAmbiguous1.class, - kind = Kind.WARNING, - line = 56, - messageRegExp = "Unmapped target properties: \"stringPropX, integerPropX\"" ) - } + value = CompilationResult.FAILED, + diagnostics = { + @Diagnostic(type = SourceTargetMapperAmbiguous1.class, + kind = Kind.ERROR, + line = 49, + messageRegExp = "Several matching inverse methods exist: forward\\(\\), " + + "forwardNotToReverse\\(\\). Specify a name explicitly."), + @Diagnostic(type = SourceTargetMapperAmbiguous1.class, + kind = Kind.WARNING, + line = 54, + messageRegExp = "Unmapped target properties: \"stringPropX, integerPropX\"") + } ) public void shouldRaiseAmbiguousReverseMethodError() { } @Test - @WithClasses( { SourceTargetMapperAmbiguous2.class } ) + @WithClasses({ SourceTargetMapperAmbiguous2.class }) @ExpectedCompilationOutcome( - value = CompilationResult.FAILED, - diagnostics = { - @Diagnostic( type = SourceTargetMapperAmbiguous2.class, - kind = Kind.ERROR, - line = 51, - messageRegExp = "None of the candidates forward\\(\\), forwardNotToReverse\\(\\) matches given " - + "name: \"blah\"." ), - @Diagnostic( type = SourceTargetMapperAmbiguous2.class, - kind = Kind.WARNING, - line = 56, - messageRegExp = "Unmapped target properties: \"stringPropX, integerPropX\"" ) - } + value = CompilationResult.FAILED, + diagnostics = { + @Diagnostic(type = SourceTargetMapperAmbiguous2.class, + kind = Kind.ERROR, + line = 49, + messageRegExp = "None of the candidates forward\\(\\), forwardNotToReverse\\(\\) matches given " + + "name: \"blah\"."), + @Diagnostic(type = SourceTargetMapperAmbiguous2.class, + kind = Kind.WARNING, + line = 54, + messageRegExp = "Unmapped target properties: \"stringPropX, integerPropX\"") + } ) public void shouldRaiseAmbiguousReverseMethodErrorWrongName() { } @Test - @WithClasses( { SourceTargetMapperAmbiguous3.class } ) + @WithClasses({ SourceTargetMapperAmbiguous3.class }) @ExpectedCompilationOutcome( - value = CompilationResult.FAILED, - diagnostics = { - @Diagnostic( type = SourceTargetMapperAmbiguous3.class, - kind = Kind.ERROR, - line = 52, - messageRegExp = "Given name \"forward\" matches several candidate methods: .*forward.*\\(\\), " - + ".*forward.*\\(\\)" ), - @Diagnostic( type = SourceTargetMapperAmbiguous3.class, - kind = Kind.WARNING, - line = 57, - messageRegExp = "Unmapped target properties: \"stringPropX, integerPropX\"" ) - } + value = CompilationResult.FAILED, + diagnostics = { + @Diagnostic(type = SourceTargetMapperAmbiguous3.class, + kind = Kind.ERROR, + line = 50, + messageRegExp = "Given name \"forward\" matches several candidate methods: .*forward.*\\(\\), " + + ".*forward.*\\(\\)"), + @Diagnostic(type = SourceTargetMapperAmbiguous3.class, + kind = Kind.WARNING, + line = 55, + messageRegExp = "Unmapped target properties: \"stringPropX, integerPropX\"") + } ) public void shouldRaiseAmbiguousReverseMethodErrorDuplicatedName() { } @Test - @WithClasses( { SourceTargetMapperErroneouslyAnnotated.class } ) + @WithClasses({ SourceTargetMapperErroneouslyAnnotated.class }) @ExpectedCompilationOutcome( - value = CompilationResult.FAILED, - diagnostics = { - @Diagnostic( type = SourceTargetMapperErroneouslyAnnotated.class, - kind = Kind.ERROR, - line = 51, - messageRegExp = "Resolved inverse mapping method reverse\\(\\) should not carry the " - + "@InheritInverseConfiguration annotation itself." ) - } + value = CompilationResult.FAILED, + diagnostics = { + @Diagnostic(type = SourceTargetMapperErroneouslyAnnotated.class, + kind = Kind.ERROR, + line = 49, + messageRegExp = "Resolved inverse mapping method reverse\\(\\) should not carry the " + + "@InheritInverseConfiguration annotation itself.") + } ) public void shouldUseWronglyAnnotatedError() { } @Test - @WithClasses( { SourceTargetMapperNonMatchingName.class } ) + @WithClasses({ SourceTargetMapperNonMatchingName.class }) @ExpectedCompilationOutcome( - value = CompilationResult.FAILED, - diagnostics = { - @Diagnostic( type = SourceTargetMapperNonMatchingName.class, - kind = Kind.ERROR, - line = 44, - messageRegExp = "Given name \"blah\" does not match the only candidate. Did you mean: " - + "\"forward\"." ), - @Diagnostic( type = SourceTargetMapperNonMatchingName.class, - kind = Kind.WARNING, - line = 49, - messageRegExp = "Unmapped target properties: \"stringPropX, integerPropX\"" ) - } + value = CompilationResult.FAILED, + diagnostics = { + @Diagnostic(type = SourceTargetMapperNonMatchingName.class, + kind = Kind.ERROR, + line = 42, + messageRegExp = "Given name \"blah\" does not match the only candidate. Did you mean: " + + "\"forward\"."), + @Diagnostic(type = SourceTargetMapperNonMatchingName.class, + kind = Kind.WARNING, + line = 47, + messageRegExp = "Unmapped target properties: \"stringPropX, integerPropX\"") + } ) public void shouldAdviseOnSpecifyingCorrectName() { } diff --git a/processor/src/test/java/org/mapstruct/ap/test/reverse/Source.java b/processor/src/test/java/org/mapstruct/ap/test/reverse/Source.java index c1758cb17..eda251ca0 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/reverse/Source.java +++ b/processor/src/test/java/org/mapstruct/ap/test/reverse/Source.java @@ -19,7 +19,6 @@ package org.mapstruct.ap.test.reverse; /** - * * @author Sjaak Derksen */ public class Source { @@ -36,7 +35,7 @@ public class Source { return stringPropX; } - public void setStringPropX( String stringPropX ) { + public void setStringPropX(String stringPropX) { this.stringPropX = stringPropX; } @@ -44,7 +43,7 @@ public class Source { return integerPropX; } - public void setIntegerPropX( Integer integerPropX ) { + public void setIntegerPropX(Integer integerPropX) { this.integerPropX = integerPropX; } @@ -52,7 +51,7 @@ public class Source { return someConstantDownstream; } - public void setSomeConstantDownstream( String someConstantDownstream ) { + public void setSomeConstantDownstream(String someConstantDownstream) { this.someConstantDownstream = someConstantDownstream; } @@ -60,7 +59,7 @@ public class Source { return propertyToIgnoreDownstream; } - public void setPropertyToIgnoreDownstream( String propertyToIgnoreDownstream ) { + public void setPropertyToIgnoreDownstream(String propertyToIgnoreDownstream) { this.propertyToIgnoreDownstream = propertyToIgnoreDownstream; } diff --git a/processor/src/test/java/org/mapstruct/ap/test/reverse/SourceTargetMapper.java b/processor/src/test/java/org/mapstruct/ap/test/reverse/SourceTargetMapper.java index a71b82dcb..82a07d590 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/reverse/SourceTargetMapper.java +++ b/processor/src/test/java/org/mapstruct/ap/test/reverse/SourceTargetMapper.java @@ -25,33 +25,31 @@ import org.mapstruct.Mappings; import org.mapstruct.factory.Mappers; /** - * * @author Sjaak Derksen */ - @Mapper public interface SourceTargetMapper { SourceTargetMapper INSTANCE = Mappers.getMapper( SourceTargetMapper.class ); - @Mappings( { - @Mapping( source = "stringPropX", target = "stringPropY" ), - @Mapping( source = "integerPropX", target = "integerPropY" ), - @Mapping( source = "propertyToIgnoreDownstream", target = "propertyNotToIgnoreUpstream" ) - } ) - Target forward( Source source ); + @Mappings({ + @Mapping(source = "stringPropX", target = "stringPropY"), + @Mapping(source = "integerPropX", target = "integerPropY"), + @Mapping(source = "propertyToIgnoreDownstream", target = "propertyNotToIgnoreUpstream") + }) + Target forward(Source source); - @Mappings( { - @Mapping( source = "stringPropX", target = "stringPropY" ), - @Mapping( source = "integerPropX", target = "integerPropY" ), - @Mapping( source = "propertyToIgnoreDownstream", target = "propertyNotToIgnoreUpstream" ) - } ) - Target forwardNotToReverse( Source source ); + @Mappings({ + @Mapping(source = "stringPropX", target = "stringPropY"), + @Mapping(source = "integerPropX", target = "integerPropY"), + @Mapping(source = "propertyToIgnoreDownstream", target = "propertyNotToIgnoreUpstream") + }) + Target forwardNotToReverse(Source source); - @InheritInverseConfiguration( name = "forward" ) - @Mappings( { - @Mapping( target = "someConstantDownstream", constant = "test" ), - @Mapping( source = "propertyToIgnoreDownstream", ignore = true ) - } ) - Source reverse( Target target ); + @InheritInverseConfiguration(name = "forward") + @Mappings({ + @Mapping(target = "someConstantDownstream", constant = "test"), + @Mapping(source = "propertyToIgnoreDownstream", ignore = true) + }) + Source reverse(Target target); } diff --git a/processor/src/test/java/org/mapstruct/ap/test/reverse/SourceTargetMapperAmbiguous1.java b/processor/src/test/java/org/mapstruct/ap/test/reverse/SourceTargetMapperAmbiguous1.java index d8e5d5f4c..d167fa88f 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/reverse/SourceTargetMapperAmbiguous1.java +++ b/processor/src/test/java/org/mapstruct/ap/test/reverse/SourceTargetMapperAmbiguous1.java @@ -18,40 +18,38 @@ */ package org.mapstruct.ap.test.reverse; +import org.mapstruct.InheritInverseConfiguration; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.Mappings; -import org.mapstruct.InheritInverseConfiguration; import org.mapstruct.factory.Mappers; /** - * * @author Sjaak Derksen */ - @Mapper public interface SourceTargetMapperAmbiguous1 { SourceTargetMapperAmbiguous1 INSTANCE = Mappers.getMapper( SourceTargetMapperAmbiguous1.class ); - @Mappings( { - @Mapping( source = "stringPropX", target = "stringPropY" ), - @Mapping( source = "integerPropX", target = "integerPropY" ), - @Mapping( source = "propertyToIgnoreDownstream", target = "propertyNotToIgnoreUpstream" ) - } ) - Target forward( Source source ); + @Mappings({ + @Mapping(source = "stringPropX", target = "stringPropY"), + @Mapping(source = "integerPropX", target = "integerPropY"), + @Mapping(source = "propertyToIgnoreDownstream", target = "propertyNotToIgnoreUpstream") + }) + Target forward(Source source); - @Mappings( { - @Mapping( source = "stringPropX", target = "stringPropY" ), - @Mapping( source = "integerPropX", target = "integerPropY" ), - @Mapping( source = "propertyToIgnoreDownstream", target = "propertyNotToIgnoreUpstream" ) - } ) - Target forwardNotToReverse( Source source ); + @Mappings({ + @Mapping(source = "stringPropX", target = "stringPropY"), + @Mapping(source = "integerPropX", target = "integerPropY"), + @Mapping(source = "propertyToIgnoreDownstream", target = "propertyNotToIgnoreUpstream") + }) + Target forwardNotToReverse(Source source); @InheritInverseConfiguration - @Mappings( { - @Mapping( target = "someConstantDownstream", constant = "test" ), - @Mapping( source = "propertyToIgnoreDownstream", ignore = true ) - } ) - Source reverse( Target target ); + @Mappings({ + @Mapping(target = "someConstantDownstream", constant = "test"), + @Mapping(source = "propertyToIgnoreDownstream", ignore = true) + }) + Source reverse(Target target); } diff --git a/processor/src/test/java/org/mapstruct/ap/test/reverse/SourceTargetMapperAmbiguous2.java b/processor/src/test/java/org/mapstruct/ap/test/reverse/SourceTargetMapperAmbiguous2.java index 599122629..e9b75adfe 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/reverse/SourceTargetMapperAmbiguous2.java +++ b/processor/src/test/java/org/mapstruct/ap/test/reverse/SourceTargetMapperAmbiguous2.java @@ -25,33 +25,31 @@ import org.mapstruct.Mappings; import org.mapstruct.factory.Mappers; /** - * * @author Sjaak Derksen */ - @Mapper public interface SourceTargetMapperAmbiguous2 { SourceTargetMapperAmbiguous2 INSTANCE = Mappers.getMapper( SourceTargetMapperAmbiguous2.class ); - @Mappings( { - @Mapping( source = "stringPropX", target = "stringPropY" ), - @Mapping( source = "integerPropX", target = "integerPropY" ), - @Mapping( source = "propertyToIgnoreDownstream", target = "propertyNotToIgnoreUpstream" ) - } ) - Target forward( Source source ); + @Mappings({ + @Mapping(source = "stringPropX", target = "stringPropY"), + @Mapping(source = "integerPropX", target = "integerPropY"), + @Mapping(source = "propertyToIgnoreDownstream", target = "propertyNotToIgnoreUpstream") + }) + Target forward(Source source); - @Mappings( { - @Mapping( source = "stringPropX", target = "stringPropY" ), - @Mapping( source = "integerPropX", target = "integerPropY" ), - @Mapping( source = "propertyToIgnoreDownstream", target = "propertyNotToIgnoreUpstream" ) - } ) - Target forwardNotToReverse( Source source ); + @Mappings({ + @Mapping(source = "stringPropX", target = "stringPropY"), + @Mapping(source = "integerPropX", target = "integerPropY"), + @Mapping(source = "propertyToIgnoreDownstream", target = "propertyNotToIgnoreUpstream") + }) + Target forwardNotToReverse(Source source); - @InheritInverseConfiguration( name = "blah" ) - @Mappings( { - @Mapping( target = "someConstantDownstream", constant = "test" ), - @Mapping( source = "propertyToIgnoreDownstream", ignore = true ) - } ) - Source reverse( Target target ); + @InheritInverseConfiguration(name = "blah") + @Mappings({ + @Mapping(target = "someConstantDownstream", constant = "test"), + @Mapping(source = "propertyToIgnoreDownstream", ignore = true) + }) + Source reverse(Target target); } diff --git a/processor/src/test/java/org/mapstruct/ap/test/reverse/SourceTargetMapperAmbiguous3.java b/processor/src/test/java/org/mapstruct/ap/test/reverse/SourceTargetMapperAmbiguous3.java index ca4ed42e7..36c631973 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/reverse/SourceTargetMapperAmbiguous3.java +++ b/processor/src/test/java/org/mapstruct/ap/test/reverse/SourceTargetMapperAmbiguous3.java @@ -26,33 +26,31 @@ import org.mapstruct.Mappings; import org.mapstruct.factory.Mappers; /** - * * @author Sjaak Derksen */ - @Mapper public interface SourceTargetMapperAmbiguous3 { SourceTargetMapperAmbiguous3 INSTANCE = Mappers.getMapper( SourceTargetMapperAmbiguous3.class ); - @Mappings( { - @Mapping( source = "stringPropX", target = "stringPropY" ), - @Mapping( source = "integerPropX", target = "integerPropY" ), - @Mapping( source = "propertyToIgnoreDownstream", target = "propertyNotToIgnoreUpstream" ) - } ) - Target forward( Source source ); + @Mappings({ + @Mapping(source = "stringPropX", target = "stringPropY"), + @Mapping(source = "integerPropX", target = "integerPropY"), + @Mapping(source = "propertyToIgnoreDownstream", target = "propertyNotToIgnoreUpstream") + }) + Target forward(Source source); - @Mappings( { - @Mapping( source = "stringPropX", target = "stringPropY" ), - @Mapping( source = "integerPropX", target = "integerPropY" ), - @Mapping( source = "propertyToIgnoreDownstream", target = "propertyNotToIgnoreUpstream" ) - } ) - Target forward( Source source, @MappingTarget Target target ); + @Mappings({ + @Mapping(source = "stringPropX", target = "stringPropY"), + @Mapping(source = "integerPropX", target = "integerPropY"), + @Mapping(source = "propertyToIgnoreDownstream", target = "propertyNotToIgnoreUpstream") + }) + Target forward(Source source, @MappingTarget Target target); - @InheritInverseConfiguration( name = "forward" ) - @Mappings( { - @Mapping( target = "someConstantDownstream", constant = "test" ), - @Mapping( source = "propertyToIgnoreDownstream", ignore = true ) - } ) - Source reverse( Target target ); + @InheritInverseConfiguration(name = "forward") + @Mappings({ + @Mapping(target = "someConstantDownstream", constant = "test"), + @Mapping(source = "propertyToIgnoreDownstream", ignore = true) + }) + Source reverse(Target target); } diff --git a/processor/src/test/java/org/mapstruct/ap/test/reverse/SourceTargetMapperErroneouslyAnnotated.java b/processor/src/test/java/org/mapstruct/ap/test/reverse/SourceTargetMapperErroneouslyAnnotated.java index 9af307e08..dd8679424 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/reverse/SourceTargetMapperErroneouslyAnnotated.java +++ b/processor/src/test/java/org/mapstruct/ap/test/reverse/SourceTargetMapperErroneouslyAnnotated.java @@ -25,34 +25,32 @@ import org.mapstruct.Mappings; import org.mapstruct.factory.Mappers; /** - * * @author Sjaak Derksen */ - @Mapper public interface SourceTargetMapperErroneouslyAnnotated { SourceTargetMapperErroneouslyAnnotated INSTANCE = Mappers.getMapper( SourceTargetMapperErroneouslyAnnotated.class ); - @Mappings( { - @Mapping( source = "stringPropX", target = "stringPropY" ), - @Mapping( source = "integerPropX", target = "integerPropY" ), - @Mapping( source = "propertyToIgnoreDownstream", target = "propertyNotToIgnoreUpstream" ) - } ) - Target forward( Source source ); + @Mappings({ + @Mapping(source = "stringPropX", target = "stringPropY"), + @Mapping(source = "integerPropX", target = "integerPropY"), + @Mapping(source = "propertyToIgnoreDownstream", target = "propertyNotToIgnoreUpstream") + }) + Target forward(Source source); - @InheritInverseConfiguration( name = "forward" ) - @Mappings( { - @Mapping( target = "someConstantDownstream", constant = "test" ), - @Mapping( source = "propertyToIgnoreDownstream", ignore = true ) - } ) - Source reverse( Target target ); + @InheritInverseConfiguration(name = "forward") + @Mappings({ + @Mapping(target = "someConstantDownstream", constant = "test"), + @Mapping(source = "propertyToIgnoreDownstream", ignore = true) + }) + Source reverse(Target target); - @InheritInverseConfiguration( name = "reverse" ) - @Mappings( { - @Mapping( source = "stringPropX", target = "stringPropY" ), - @Mapping( source = "integerPropX", target = "integerPropY" ), - @Mapping( source = "propertyToIgnoreDownstream", target = "propertyNotToIgnoreUpstream" ) - } ) - Target forward2( Source source ); + @InheritInverseConfiguration(name = "reverse") + @Mappings({ + @Mapping(source = "stringPropX", target = "stringPropY"), + @Mapping(source = "integerPropX", target = "integerPropY"), + @Mapping(source = "propertyToIgnoreDownstream", target = "propertyNotToIgnoreUpstream") + }) + Target forward2(Source source); } diff --git a/processor/src/test/java/org/mapstruct/ap/test/reverse/SourceTargetMapperNonMatchingName.java b/processor/src/test/java/org/mapstruct/ap/test/reverse/SourceTargetMapperNonMatchingName.java index 0303c4f94..005021ead 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/reverse/SourceTargetMapperNonMatchingName.java +++ b/processor/src/test/java/org/mapstruct/ap/test/reverse/SourceTargetMapperNonMatchingName.java @@ -25,26 +25,24 @@ import org.mapstruct.Mappings; import org.mapstruct.factory.Mappers; /** - * * @author Sjaak Derksen */ - @Mapper public interface SourceTargetMapperNonMatchingName { SourceTargetMapperNonMatchingName INSTANCE = Mappers.getMapper( SourceTargetMapperNonMatchingName.class ); - @Mappings( { - @Mapping( source = "stringPropX", target = "stringPropY" ), - @Mapping( source = "integerPropX", target = "integerPropY" ), - @Mapping( source = "propertyToIgnoreDownstream", target = "propertyNotToIgnoreUpstream" ) - } ) - Target forward( Source source ); + @Mappings({ + @Mapping(source = "stringPropX", target = "stringPropY"), + @Mapping(source = "integerPropX", target = "integerPropY"), + @Mapping(source = "propertyToIgnoreDownstream", target = "propertyNotToIgnoreUpstream") + }) + Target forward(Source source); - @InheritInverseConfiguration( name = "blah" ) - @Mappings( { - @Mapping( target = "someConstantDownstream", constant = "test" ), - @Mapping( source = "propertyToIgnoreDownstream", ignore = true ) - } ) - Source reverse( Target target ); + @InheritInverseConfiguration(name = "blah") + @Mappings({ + @Mapping(target = "someConstantDownstream", constant = "test"), + @Mapping(source = "propertyToIgnoreDownstream", ignore = true) + }) + Source reverse(Target target); } diff --git a/processor/src/test/java/org/mapstruct/ap/test/reverse/Target.java b/processor/src/test/java/org/mapstruct/ap/test/reverse/Target.java index 8cd72aefa..376a4bf3c 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/reverse/Target.java +++ b/processor/src/test/java/org/mapstruct/ap/test/reverse/Target.java @@ -19,7 +19,6 @@ package org.mapstruct.ap.test.reverse; /** - * * @author Sjaak Derksen */ public class Target { @@ -34,7 +33,7 @@ public class Target { return stringPropY; } - public void setStringPropY( String stringPropY ) { + public void setStringPropY(String stringPropY) { this.stringPropY = stringPropY; } @@ -42,7 +41,7 @@ public class Target { return integerPropY; } - public void setIntegerPropY( Integer integerPropY ) { + public void setIntegerPropY(Integer integerPropY) { this.integerPropY = integerPropY; } @@ -50,7 +49,7 @@ public class Target { return propertyNotToIgnoreUpstream; } - public void setPropertyNotToIgnoreUpstream( String propertyNotToIgnoreUpstream ) { + public void setPropertyNotToIgnoreUpstream(String propertyNotToIgnoreUpstream) { this.propertyNotToIgnoreUpstream = propertyNotToIgnoreUpstream; }