-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
Discussed in #3724
Originally posted by rmschots September 25, 2024
Currently the DefaultBuilderProvider only detects builders if there is a static builder factory method available.
As I'm trying to use Wire (https://github.com/square/wire), and it only generates the inner builder class, I'd like to have mapstruct detect and use that builder class out of the box.
I brought us this issue at the Wire repository (square/wire#3073), but the introduction of a static factory method for the builder got rejected.
I think it's either way more appropriate to add support in mapstruct out of the box.
I created an SPI that adds this support, but I prefer to have this baked into mapstruct.
I could open a PR if needed.
an example of target that cannot be used for mapping:
public class SomeTarget {
private final String someField;
private SomeTarget(String someField) {
this.someField = someField;
}
public static class SomeTargetBuilder {
private String someField;
public SomeTargetBuilder someField(String someField) {
this.someField = someField;
return this;
}
public SomeTarget build() {
return new SomeTarget(this.someField);
}
}
}
Trying to generate a mapper would currently produce the following error: SomeTarget does not have an accessible constructor.