initial version
This commit is contained in:
70
README.md
70
README.md
@ -1,3 +1,71 @@
|
||||
# mapstruct-support
|
||||
|
||||
Additional DefaultAccessorNamingStrategy to support fluent API withXYZ setters.
|
||||
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 are therefore cause an error, when the mapper is annotated with
|
||||
`unmappedTargetPolicy = ReportingPolicy.ERROR`.
|
||||
|
||||
## Installation
|
||||
|
||||
To use the extended naming strategy, just include it as project dependency alongside with mapstruct.
|
||||
|
||||
```xml
|
||||
|
||||
<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
|
||||
|
||||
```java
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user