1

I recently started using the Immutables library, and I'm puzzled by the following behavior:

Given the following abstract value type

@Value.Immutable
public abstract class Foo {
    public abstract String bar();

    public abstract List<String> baz();
}

attempting to build an object like so

ImmutableFoo.builder()
    .baz(List.of("1", "2", "3"))
    .build()

fails because

some of required attributes are not set [bar]

yet

ImmutableFoo.builder()
    .bar("1, 2, 3")
    .build()

is fine, and there is no objection that baz has not been set.

Why do collection attributes receive different treatment?

Isaac Kleinman
  • 3,994
  • 3
  • 31
  • 35
  • 1
    They explicitly stated in their own documentation that "When building using builders, the contents of collection attributes can be left unspecified". You need to ask _them_ why, not _us_. – Tom Jan 05 '23 at 17:43
  • 1
    done: https://github.com/immutables/immutables/issues/1429 – Isaac Kleinman Jan 05 '23 at 18:00

0 Answers0