#400 fix nested property mappings with Eclipse JDT compiler, extend the integration test accordingly.

This commit is contained in:
Andreas Gudian 2014-12-29 16:17:00 +01:00
parent 2435f0206a
commit 640d9dd571
6 changed files with 29 additions and 3 deletions

View File

@ -26,6 +26,7 @@ public class Source {
private Long baz; private Long baz;
private int zip; private int zip;
private String someType; private String someType;
private SomeType forNested;
public int getFoo() { public int getFoo() {
return foo; return foo;
@ -74,4 +75,12 @@ public class Source {
public void setSomeType(String someType) { public void setSomeType(String someType) {
this.someType = someType; this.someType = someType;
} }
public SomeType getForNested() {
return forNested;
}
public void setForNested(SomeType forNested) {
this.forNested = forNested;
}
} }

View File

@ -30,10 +30,12 @@ public abstract class SourceTargetAbstractMapper {
@Mappings({ @Mappings({
@Mapping(source = "qax", target = "baz"), @Mapping(source = "qax", target = "baz"),
@Mapping(source = "baz", target = "qax") @Mapping(source = "baz", target = "qax"),
@Mapping(source = "forNested.value", target = "fromNested")
}) })
public abstract Target sourceToTarget(Source source); public abstract Target sourceToTarget(Source source);
@Mapping(target = "forNested", ignore = true)
public abstract Source targetToSource(Target target); public abstract Source targetToSource(Target target);
protected void isNeverCalled(Source source) { protected void isNeverCalled(Source source) {

View File

@ -31,10 +31,12 @@ public interface SourceTargetMapper {
@Mappings({ @Mappings({
@Mapping(source = "qax", target = "baz"), @Mapping(source = "qax", target = "baz"),
@Mapping(source = "baz", target = "qax") @Mapping(source = "baz", target = "qax"),
@Mapping(source = "forNested.value", target = "fromNested")
}) })
Target sourceToTarget(Source source); Target sourceToTarget(Source source);
@InheritInverseConfiguration @InheritInverseConfiguration
@Mapping(target = "forNested", ignore = true)
Source targetToSource(Target target); Source targetToSource(Target target);
} }

View File

@ -28,6 +28,7 @@ public class Target {
private int qax; private int qax;
private String zip; private String zip;
private SomeType someType; private SomeType someType;
private String fromNested;
public Long getFoo() { public Long getFoo() {
return foo; return foo;
@ -76,4 +77,12 @@ public class Target {
public void setSomeType(SomeType someType) { public void setSomeType(SomeType someType) {
this.someType = someType; this.someType = someType;
} }
public String getFormNested() {
return fromNested;
}
public void setFromNested(String fromNested) {
this.fromNested = fromNested;
}
} }

View File

@ -153,6 +153,10 @@ public class NestedPropertyMappingMethod extends MappingMethod {
public String getName() { public String getName() {
return safeName; return safeName;
} }
public String getAccessorName() {
return getAccessor().getSimpleName().toString();
}
} }
} }

View File

@ -24,7 +24,7 @@
return ${returnType.null}; return ${returnType.null};
} }
<#list propertyEntries as entry> <#list propertyEntries as entry>
<@includeModel object=entry.type/> ${entry.name} = <#if entry_index == 0>${sourceParameter.name}.${entry.accessor}<#else>${propertyEntries[entry_index-1].name}.${entry.accessor}</#if>; <@includeModel object=entry.type/> ${entry.name} = <#if entry_index == 0>${sourceParameter.name}.${entry.accessorName}()<#else>${propertyEntries[entry_index-1].name}.${entry.accessorName}()</#if>;
<#if !entry.type.primitive> <#if !entry.type.primitive>
if ( ${entry.name} == null ) { if ( ${entry.name} == null ) {
return ${returnType.null}; return ${returnType.null};