forked from mapstruct/mapstruct
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mapstruct#3670 Fix regression when using `InheritInverseConfiguration…
…` with nested target properties and reversing `target = "."`
- Loading branch information
Showing
4 changed files
with
106 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
processor/src/test/java/org/mapstruct/ap/test/bugs/_3670/Issue3670Mapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* Copyright MapStruct Authors. | ||
* | ||
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
package org.mapstruct.ap.test.bugs._3670; | ||
|
||
import org.mapstruct.InheritInverseConfiguration; | ||
import org.mapstruct.Mapper; | ||
import org.mapstruct.Mapping; | ||
import org.mapstruct.Named; | ||
|
||
/** | ||
* @author Filip Hrisafov | ||
*/ | ||
@Mapper | ||
public interface Issue3670Mapper { | ||
|
||
@Mapping(target = "name", source = ".", qualifiedByName = "nestedName") | ||
Target map(Source source); | ||
|
||
@InheritInverseConfiguration | ||
@Mapping(target = "nested.nestedName", source = "name") | ||
Source map(Target target); | ||
|
||
@Named("nestedName") | ||
default String mapNestedName(Source source) { | ||
if ( source == null ) { | ||
return null; | ||
} | ||
|
||
Nested nested = source.getNested(); | ||
|
||
return nested != null ? nested.getNestedName() : null; | ||
} | ||
|
||
|
||
class Target { | ||
|
||
private String name; | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
} | ||
|
||
class Nested { | ||
private String nestedName; | ||
|
||
public String getNestedName() { | ||
return nestedName; | ||
} | ||
|
||
public void setNestedName(String nestedName) { | ||
this.nestedName = nestedName; | ||
} | ||
} | ||
|
||
class Source { | ||
|
||
private Nested nested; | ||
|
||
public Nested getNested() { | ||
return nested; | ||
} | ||
|
||
public void setNested(Nested nested) { | ||
this.nested = nested; | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
processor/src/test/java/org/mapstruct/ap/test/bugs/_3670/Issue3670Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Copyright MapStruct Authors. | ||
* | ||
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
package org.mapstruct.ap.test.bugs._3670; | ||
|
||
import org.mapstruct.ap.testutil.IssueKey; | ||
import org.mapstruct.ap.testutil.ProcessorTest; | ||
import org.mapstruct.ap.testutil.WithClasses; | ||
|
||
/** | ||
* @author Filip Hrisafov | ||
*/ | ||
@IssueKey("3670") | ||
@WithClasses(Issue3670Mapper.class) | ||
class Issue3670Test { | ||
|
||
@ProcessorTest | ||
void shouldCompile() { | ||
} | ||
} |