Skip to content

Instantly share code, notes, and snippets.

@lujop
Created December 5, 2017 22:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lujop/e53d46eeaca432c444ec1c7fa4110827 to your computer and use it in GitHub Desktop.
Save lujop/e53d46eeaca432c444ec1c7fa4110827 to your computer and use it in GitHub Desktop.
Gist for Mapstruct #1345 Ignore doesn't works for readonly properties
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