mapstruct / mapstruct/mapstruct
Lombok's fluent accessors are discovered in builders, but not for getters
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 7.7k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
### Expected behavior
Mapstruct is able to detect and map fluent properties back and forth when using lombok's `@Accessors(fluent = true)` annotation.
This was asked previously by someone in [this stackoverflow question](https://stackoverflow.com/questions/48724814/accessorsfluent-true-from-lombok-and-mapstruct-together) where @filiphr suggested writing a custom AccessorNamingStrategy, but I am unsure if this is still expected since mapstruct has since then added lombok and builders support.
### Actual behavior
Mapstruct errors with:
```
Error:(9, 5) java: No property named "fluentProp" exists in source parameter(s)...
```
### Steps to reproduce the problem
```java
@Value
@Builder
class Animal {
@Accessors(fluent = true)
boolean hasLegs;
}
@Value
@Builder
class Cat {
@Accessors(fluent = true)
boolean hasLegs;
}
@Mapper
public interface AnimalMapper {
@Mapping(target = "hasLegs", source = "hasLegs")
Cat toCat(Animal animal);
}
```
For this example, Mapstruct errors with:
```
Error:(9, 5) java: No property named "hasLegs" exists in source parameter(s). Type "Animal" has no properties.
```
It's interesting to note that hasLegs is detected correctly in the target since the builder accessors are always fluent, but just not in the source.
### MapStruct Version
1.5.5.Final
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the annotation processor's accessor-naming and Lombok/builder handling, then run the fluent @Accessors(fluent = true) reproduction shown in the issue. Done means MapStruct recognizes the source hasLegs property as well as the builder target and the Animal-to-Cat mapping compiles without the reported error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100