Skip to content

Conversation

@nastra
Copy link
Contributor

@nastra nastra commented Jun 14, 2023

I've mainly opened this PR as a discussion point to have an alternative to writing manual builders for classes that we can't or don't want to switch to @Value.Immutable.

The Immutables lib can also be used to generate a Builder without having to annotate a class with @Value.Immutable. It's worth mentioning that this is mainly for use cases where we don't require additional processing logic in the builders.

import org.immutables.builder.Builder.Constructor;
import org.immutables.value.Value;

@Value.Style(newBuilder = "newBuilder")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without this, one would instantiate the Builder via new UpdateTableRequestBuilder(), which is probably fine as well. We could also add

public static UpdateTableRequestBuilder builder() {
    return new UpdateTableRequestBuilder();
}

to UpdateTableRequest

this.updates = updates;
}

@Constructor
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will generate a Builder class from the constructor params and we're indicating in the constructor that TableIdentifier can be null.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the constructor needs to be non-private (we could also change it to protected to be more strict and force usage via the generated builder

@nastra nastra marked this pull request as draft June 14, 2023 09:16
@nastra nastra requested a review from rdblue June 14, 2023 09:16
@nastra nastra closed this Jul 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant