While using @Builder
Is there any annotation to mark a field of type Collection in a class, that its add method would support passing variable length arguments ?
If not , is there a plan to add or support one ?
Not that I know of. There are ways to quickly get collections though -
Arrays.asList() is a good start. Or for empty / single element lists,
Collections.emptyList(), Collections.singleton(), etc.
On Wed, Jan 31, 2018 at 4:33 AM, Mithun notifications@github.com wrote:
If not , is there a plan to add or support one ?
—
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/1568#issuecomment-361813201,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAKCRZP46szuHXAKYRgKJnfQK9VjdvDSks5tP976gaJpZM4RxfDc
.
--
"Don't only practice your art, but force your way into it's secrets, for it
and knowledge can raise men to the divine."
-- Ludwig von Beethoven
No there is not, nor are there any plans.
If you annotate your collection field with @Singular, you can use chaining to get similar results:
@Builder
class Foo {
@Singular
List<String> names;
}
Foo create() {
return Foo.builder().name("Bob").name("Alice").build();
}
Is that good enough?
Yup, that works.
thanks
@Builder doesn't work for enums
@Danon having an enum with a collection you can add to sounds like an extremely ill advised plan. I assume you have something else in mind but it's not clear what. Proposals or ideas are best put in the form of 'this is what it looks like without lombok' and 'this is what it looks like with lombok'.
Most helpful comment
No there is not, nor are there any plans.
If you annotate your collection field with
@Singular, you can use chaining to get similar results:Is that good enough?