660be27f1a5ae9392e25a405e887ac3277655208
mapstruct-support
Additional DefaultAccessorNamingStrategy to support fluent API withXYZ setters.
Mapstruct default naming strategy detects the methods withFirstName and withLastName (see example below) as extra
target fields and therefore cause an error, when the mapper is annotated with
unmappedTargetPolicy = ReportingPolicy.ERROR.
The additional naming strategy makes Mapstruct ignore the withXYZ setters.
Installation
To use the extended naming strategy, just include it as project dependency alongside with mapstruct.
<dependencies>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>1.4.2.Final</version>
</dependency>
<dependency>
<groupId>de.muehlencord.mapstruct</groupId>
<artifactId>mapstruct-support</artifactId>
<version>1.4.2</version>
</dependency>
</dependencies>
Example
public class Person {
private String firstName;
private String lastName;
// standard getter / setter - these are covered by mapstruct by default */
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
/* fluent setter - these are detected as extra setters and would
cause an mapping exception, if the mapper is annotated with
unmappedTargetPolicy = ReportingPolicy.ERROR.
*/
public Person withFirstName(String firstName) {
this.firstName = firstName;
return this;
}
public Person withLastName(String lastName) {
this.lastName = lastName;
return this;
}
}
Description
mapstruct-support-1.6.3
Latest
Languages
Java
100%