This commit is contained in:
Gunnar Morling 2014-10-14 22:03:07 +02:00
parent 32eeceb0cf
commit 4d408d5560
10 changed files with 243 additions and 240 deletions

View File

@ -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<List<Sourc
else if ( method.isEnumMapping() ) {
EnumMappingMethod.Builder builder = new EnumMappingMethod.Builder();
mergeWithReverseMappings( reverseMappingMethod, method);
mergeWithReverseMappings( reverseMappingMethod, method );
if ( method.getMappings().isEmpty() ) {
if ( reverseMappingMethod != null && !reverseMappingMethod.getMappings().isEmpty() ) {
method.setMappings( reverse( reverseMappingMethod.getMappings() ) );
@ -331,7 +330,7 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Sourc
else {
BeanMappingMethod.Builder builder = new BeanMappingMethod.Builder();
mergeWithReverseMappings( reverseMappingMethod, method);
mergeWithReverseMappings( reverseMappingMethod, method );
BeanMappingMethod beanMappingMethod = builder
.mappingContext( mappingContext )
.souceMethod( method )
@ -386,7 +385,7 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Sourc
return reversed;
}
private void mergeWithReverseMappings( SourceMethod reverseMappingMethod, SourceMethod method ) {
private void mergeWithReverseMappings(SourceMethod reverseMappingMethod, SourceMethod method) {
Map<String, List<Mapping>> newMappings = new HashMap<String, List<Mapping>>();
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<List<Sourc
}
}
private SourceMethod getReverseMappingMethod(List<SourceMethod> 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<List<Sourc
}
}
if ( nameFilteredcandidates.size() == 1 ) {
if ( nameFilteredcandidates.size() == 1 ) {
result = nameFilteredcandidates.get( 0 );
}
else if ( nameFilteredcandidates.size() > 1 ) {
@ -458,74 +457,93 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Sourc
}
if ( result != null ) {
reportErrorIfForwardMethodHasInheritInverseConfigurationAnnotation( result, method, reversePrism );
reportErrorIfInverseMethodHasInheritAnnotation( result, method, reversePrism );
}
}
return result;
}
private void reportErrorIfForwardMethodHasInheritInverseConfigurationAnnotation( SourceMethod candidate,
SourceMethod method, InheritInverseConfigurationPrism reversePrism ) {
private void reportErrorIfInverseMethodHasInheritAnnotation(SourceMethod candidate,
SourceMethod method,
InheritInverseConfigurationPrism reversePrism) {
InheritInverseConfigurationPrism candidatePrism = InheritInverseConfigurationPrism.getInstanceOn(
candidate.getExecutable()
);
InheritInverseConfigurationPrism candidatePrism = InheritInverseConfigurationPrism.getInstanceOn( candidate.getExecutable() );
if ( candidatePrism != null ) {
messager.printMessage( Diagnostic.Kind.ERROR,
String.format( "Resolved inverse mapping method %s() should not carry the "
+ "@InheritInverseConfiguration annotation itself.",
candidate.getName()
),
method.getExecutable(),
reversePrism.mirror );
messager.printMessage(
Diagnostic.Kind.ERROR,
String.format(
"Resolved inverse mapping method %s() should not carry the "
+ "@InheritInverseConfiguration annotation itself.",
candidate.getName()
),
method.getExecutable(),
reversePrism.mirror
);
}
}
private void reportErrorWhenAmbigousReverseMapping( List<SourceMethod> candidates, SourceMethod method,
InheritInverseConfigurationPrism reversePrism ) {
private void reportErrorWhenAmbigousReverseMapping(List<SourceMethod> candidates, SourceMethod method,
InheritInverseConfigurationPrism reversePrism) {
List<String> candidateNames = new ArrayList<String>();
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<SourceMethod> 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
);
}
}

View File

@ -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() {
}

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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;
}