Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/danny02/mapstruct-wither-support
Mapstruct naming strategy that supports withers.
https://github.com/danny02/mapstruct-wither-support
lombok mapstruct
Last synced: 4 days ago
JSON representation
Mapstruct naming strategy that supports withers.
- Host: GitHub
- URL: https://github.com/danny02/mapstruct-wither-support
- Owner: Danny02
- License: apache-2.0
- Created: 2023-11-09T13:25:48.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-03-11T19:59:53.000Z (10 months ago)
- Last Synced: 2024-11-08T23:47:07.552Z (about 2 months ago)
- Topics: lombok, mapstruct
- Language: Java
- Homepage:
- Size: 109 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Mapstruct Wither support
Mapstruct plugin to support `withX` methods in POJOs.
## Usage
The library needs to be added to the annotation processor
classpath. With Maven, this can be done by configuring the
compiler plugin as follows.```xml
maven-compiler-plugin
dev.nullzwo
mapstruct-wither-support
1.0.0
```
## Problem
[Mapstruct](https://mapstruct.org/) is a library to map instances
of one class to another similar class.The library has to support many different styles of writing such
POJOs. Sadly, one common style is not supported.### Withers
Withers are methods that can be used to change a single field
of an immutable POJO, by creating a copy.See for example Lomboks
[@With](https://projectlombok.org/features/With).### Mapstruct default behavior
Mapstruct will issue warning by default when this pattern is
used.```
java: Unmapped target properties: "withName".
```The reason is that Mapstruct does not understand how to parse
the property name from a `withX` method.### Solution
This library provides a small
[AccessorNamingStrategy](https://mapstruct.org/documentation/stable/reference/html/#using-spi)
that adds the capability to parse the correct property name from
`withX` methods.