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

Use SELF for Builder Self Type Parameter (part2) #5733

Merged
merged 2 commits into from
Jun 7, 2024

Conversation

minwoox
Copy link
Contributor

@minwoox minwoox commented Jun 5, 2024

Motivation:
See #5684 for the motivation.

Modifications:

  • Refactored builder classes to use the SELF type parameter for the builder's self-referencing methods.

Result:

  • Reduced the need for cumbersome and error-prone method overrides.
  • (Breaking) These are all annotated with @UnstableApi.
    • AbstractDnsResolverBuilder is now AbstractDnsResolverBuilder<SELF>
    • AbstractRuleBuilder is now AbstractRuleBuilder<SELF>
    • AbstractRuleWithContentBuilder is now AbstractRuleWithContentBuilder<SELF>
    • AbstractCircuitBreakerMappingBuilder is now AbstractCircuitBreakerMappingBuilder<SELF>
    • AbstractDynamicEndpointGroupBuilder is now AbstractDynamicEndpointGroupBuilder<SELF>
    • DynamicEndpointGroupSetters is now DynamicEndpointGroupSetters<SELF>
    • AbstractCuratorFrameworkBuilder is now AbstractCuratorFrameworkBuilder<SELF>

Motivation:
See line#5684 for the motivation.

Modifications:
- Refactored builder classes to use the SELF type parameter for the builder's self-referencing methods.

Result:
- Reduced the need for cumbersome and error-prone method overrides.
@minwoox minwoox added this to the 1.29.0 milestone Jun 5, 2024
Copy link
Contributor

@jrhee17 jrhee17 left a comment

Choose a reason for hiding this comment

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

Agree with the overall direction 👍 I'd rather not go through each change since I think it's more efficient that we fix them as we go along. Thanks @minwoox 🙇 👍 🙇

@@ -92,6 +92,14 @@ public abstract class AbstractDnsResolverBuilder {
*/
protected AbstractDnsResolverBuilder() {}

/**
* Return this.
Copy link
Member

Choose a reason for hiding this comment

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

Global comment:

Suggested change
* Return this.
* Returns {@code this}.

@@ -36,7 +36,9 @@
* @param <T> the response type
*/
@UnstableApi
public abstract class AbstractRuleWithContentBuilder<T extends Response> extends AbstractRuleBuilder {
public abstract class AbstractRuleWithContentBuilder
<T extends Response, SELF extends AbstractRuleWithContentBuilder<T, SELF>>
Copy link
Member

Choose a reason for hiding this comment

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

Global comment: Maybe SELF should come first?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! Updated. 👍

Copy link
Member

@trustin trustin left a comment

Choose a reason for hiding this comment

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

Thanks, @minwoox!

@trustin trustin merged commit d4d72aa into line:main Jun 7, 2024
15 checks passed
Dogacel pushed a commit to Dogacel/armeria that referenced this pull request Jun 8, 2024
Motivation:
See line#5684 for the motivation.

Modifications:
- Refactored builder classes to use the SELF type parameter for the
builder's self-referencing methods.

Result:
- Reduced the need for cumbersome and error-prone method overrides.
- (Breaking) These are all annotated with `@UnstableApi`.
- `AbstractDnsResolverBuilder` is now `AbstractDnsResolverBuilder<SELF>`
  - `AbstractRuleBuilder` is now `AbstractRuleBuilder<SELF>`
- `AbstractRuleWithContentBuilder` is now
`AbstractRuleWithContentBuilder<SELF>`
- `AbstractCircuitBreakerMappingBuilder` is now
`AbstractCircuitBreakerMappingBuilder<SELF>`
- `AbstractDynamicEndpointGroupBuilder` is now
`AbstractDynamicEndpointGroupBuilder<SELF>`
- `DynamicEndpointGroupSetters` is now
`DynamicEndpointGroupSetters<SELF>`
- `AbstractCuratorFrameworkBuilder` is now
`AbstractCuratorFrameworkBuilder<SELF>`
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.

4 participants