Closed
Description
Given an attribute of type Set<T>
, there is currently no way to define a default value for it.
If I try to declare it as a Set:
@Value.Default
public Set<Flavor> flavors() {
return ImmutableSet.of(Flavor.DEFAULT);
}
compilation will fail in the generated immutable subclass because it tries to set the field to the value returned by the superclass' accessor:
private final ImmutableSet<Flavor> flavors;
...
this.flavors = Preconditions.checkNotNull(super.flavors());
If I try to declare it as an ImmutableSet:
@Value.Default
public ImmutableSet<Flavor> flavors() {
return ImmutableSet.of(Flavor.DEFAULT);
}
compilation will succeed, but the builder will not have the addFlavors(Flavor... flavors)
generated collection methods.