immutables / immutables-vavr

Immutables encodings for Vavr
Other
33 stars 7 forks source link

Builder.add with VarArgs #13

Closed tmtron closed 7 years ago

tmtron commented 7 years ago

Can we change the builder.add method to accept VarArgs?

So instead of

ImmutableExampleSetType.Builder b = ImmutableExampleSetType.builder()
b.addIntegers(Integer.valueOf(0));
b.addIntegers(Integer.valueOf(1));
b.addIntegers(Integer.valueOf(2));

we can additionally use:

ImmutableExampleSetType.builder();
b.addIntegers(Integer.valueOf(0), Integer.valueOf(1), Integer.valueOf(2));

e.g. In a branch of my fork, I've implemented it for Set: see this changeset

BTW: Is there a reason why you use explicit boxing of integer types in your tests?

io7m commented 7 years ago

Can we change the builder.add method to accept VarArgs?

I'd prefer to add a method rather than change the existing one, to ensure (binary) compatibility with existing clients.

BTW: Is there a reason why you use explicit boxing of integer types in your tests?

It's habit, really. I work with a lot of code that has soft-realtime requirements (r2, etc) and so my IDE is configured to ensure that boxing is explicit. Makes it clear when code might conceivably create garbage.