Created
December 5, 2017 22:26
-
-
Save lujop/e53d46eeaca432c444ec1c7fa4110827 to your computer and use it in GitHub Desktop.
Gist for Mapstruct #1345 Ignore doesn't works for readonly properties
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
package cat.joanpujol; | |
import org.mapstruct.InheritInverseConfiguration; | |
import org.mapstruct.Mapper; | |
import org.mapstruct.Mapping; | |
public class Test { | |
} | |
class A { | |
private String readOnlyProperty; | |
public String getReadOnlyProperty() { | |
return readOnlyProperty; | |
} | |
} | |
class B { | |
private String property; | |
public String getProperty() { | |
return property; | |
} | |
public void setProperty(String property) { | |
this.property = property; | |
} | |
} | |
@Mapper | |
interface A2BMapper { | |
@Mapping(target = "property", source="readOnlyProperty") | |
B a2B(A a); | |
@InheritInverseConfiguration(name = "a2B") | |
@Mapping(target="readOnlyProperty", ignore=true) | |
A b2A(B b); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment