Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

benhalasi
Copy link
Contributor

This change-set should annotate final stage builder interfaces (BuildFinal) with CanIgnoreReturnValue, and allow downstream projects using Error Prone to use Staged Builders without method chaining or disabling the CheckReturnValue bug-checker. This aligns with the existing implementation and "normal" and strict builders.


Aside from this change, I have a broader question:

We encountered this while trying to propagate optional values to default primitive members in our immutable models. For example, the following model Foo will produce a single builder method for Foo#bar, BuildFinal bar(int bar), which cannot be called with an Optional<Integer> with method chaining, only conditionally with the optional unwrapped.

interface Foo {
  default int bar() {
    return 99;
  }
}

Have you considered generating "optional" builder methods for default non-optional members? In this example, BuildFinal bar(Optional<Integer> bar)?

I've managed to implement this for object types, but not for primitives. I didn't yet find a way to map primitives to their boxed optional types.

If this feature would be welcome, I may give it a go, and ask for you input, pointers on it.

Thanks all!

@elucash
Copy link
Member

elucash commented Jul 14, 2025

Thank you! Merging

@elucash elucash merged commit 5adba57 into immutables:master Jul 14, 2025
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants