Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Optional-wrapping property builders #444

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

octylFractal
Copy link
Contributor

I think it is worthwhile to allow Optional for properties that use property builders, so I wrote code to support such an option.

The value is an empty Optional by default, and uses Optional.of(builder.build()) to generate an Optional from the builder.

Ex:

@AutoValue
abstract class Foo {
  @AutoValue.Builder
  interface Builder {
    Nested.Builder nestedBuilder();
  }
  
  abstract Optional<Nested> nested();
}

@AutoValue
abstract class Nested {
  
  static Builder builder() {
    return new AutoValue_Nested.Builder();
  }
  
  @AutoValue.Builder
  interface Builder {
  }
}

@octylFractal
Copy link
Contributor Author

I've added the tests here as well, @eamonnmcmanus.

@octylFractal octylFractal force-pushed the feature/optional-nested-builders branch from d0cc250 to fbe3414 Compare March 12, 2017 00:06
@raghsriniv raghsriniv added P3 type=enhancement Make an existing feature better labels Oct 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes P3 type=enhancement Make an existing feature better
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants