Describe the feature
@Builder( onBuilder=@Foo )
class MyClass {
...
@Foo
class MyClassBuilder {
Describe the target audience
this is another potential solution to https://github.com/uber/NullAway/issues/321
@xenoterracide a workaround i know is just declare the builder class:
@Builder
class MyClass {
@Foo
class MyClassBuilder {}
}
This is practically how people are making Lombok and Jackson work together: https://stackoverflow.com/a/48801237/2908793
But i agree in advance that this is just a workaround, and requested functionality would be nice, since we already have this thing on @*Constructor annotations.
I'm not sure about this. The onConstructor argument is necessary as you don't wont to write a 20-args constructor declaration (and keep it up to date!) to be completed by Lombok. With the builder class, all you need to write is the empty class declaration and the annotation, so that's just a few additional chars. It also allows you to add some methods... Moreover, the on* argument may break in some future Java version, while the workaround probably won't.
So maybe the workaround is the right solution?
I tend to agree. However, with @SuperBuilder I see things a bit differently, because the declaration is quite complex, and there are 2 of them.
How complex exactly? I may need to use that at some point, not sure if this
is documented anywhere..
On Wed, Dec 4, 2019, 17:32 Jan Rieke notifications@github.com wrote:
I tend to agree. However, with @SuperBuilder I see things a bit
differently, because the declaration is quite complex, and there are 2 of
them.—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/rzwitserloot/lombok/issues/2293?email_source=notifications&email_token=AABIERO5UE3SYAAPTC42CYLQW7LTPA5CNFSM4JP4QRDKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEF5T2BY#issuecomment-561724679,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AABIERJZU6XAYFH2CRS4CSTQW7LTPANCNFSM4JP4QRDA
.
It's so complex that the documentation says: Use delombok to get it right. And I agree (I wrote it ;-).
The problem with using this on @SuperBuilder is that we then need onAbstractBuilder= _and_ onImplBuilder=, which is going a bit too far, I think.
Most people would use it for Jackson to deserialize using the builder. For that case, you only need it on the BuilderImpl. On the other hand, there is no need for a Jackson annotation if you can add a prefix. However, you still need to make the BuilderImpl at least package-private for Jackson to use it.
I'm unsure, but right now I would vote for a visibility and prefix option for @SuperBuilder.
@janrieke Unless I'm mistaken (@rzwitserloot can confirm or deny) #2174 should be included in the next release, which contains support for prefixing @Builder methods; I haven't looked at @SuperBuilder but that PR might serve as starting point
"Set" methods for @SuperBuilder can be prefixed with the next version (PR #2357), making @JsonPOJOBuilder (or setting a custom JacksonAnnotationIntrospector) unnecessary if you specify the prefix in @SuperBuilder.