8000 Default collection values are not supported · Issue #59 · immutables/immutables · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Default collection values are not supported #59
Closed
@Coneko

Description

@Coneko

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0