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

Harmonize toBuilder() implementations #4797

Open
paullatzelsperger opened this issue Feb 5, 2025 · 0 comments · Fixed by #4800
Open

Harmonize toBuilder() implementations #4797

paullatzelsperger opened this issue Feb 5, 2025 · 0 comments · Fixed by #4800
Labels
core feature enhancement New feature or request good first issue Good for newcomers triage all new issues awaiting classification

Comments

@paullatzelsperger
Copy link
Member

paullatzelsperger commented Feb 5, 2025

Feature Request

there are currently several slightly different implementations of the toBuilder() method around. We should harmonize that.

Which Areas Would Be Affected?

all classes that have a toBuilder method

Why Is the Feature Desired?

harmonization

Who will sponsor this feature?

Please @-mention the committer that will sponsor your feature.

Solution Proposal

  • the toBuilder() method is to operate on the original instance, e.g.

    public Builder toBuilder() {
          return new Builder(this);
    }

    thus, any modification is done on the original instance.

  • [optional] in addition, we could have a copy() method, which creates a completely new instance. We must be careful with deep copy vs shallow copy. This could be a sourcre for nasty bugs. Personally, I would opt for creating a deep-copy to maintain immutability of the original instance.

  • Decision Record: docs: decision record about toBuilder and copy #4800

@paullatzelsperger paullatzelsperger added core feature enhancement New feature or request labels Feb 5, 2025
@github-actions github-actions bot added the triage all new issues awaiting classification label Feb 5, 2025
@paullatzelsperger paullatzelsperger removed the triage all new issues awaiting classification label Feb 6, 2025
@paullatzelsperger paullatzelsperger added the good first issue Good for newcomers label Feb 6, 2025
@github-actions github-actions bot added the triage all new issues awaiting classification label Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core feature enhancement New feature or request good first issue Good for newcomers triage all new issues awaiting classification
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant