Remove Builder type param on RequestComponentBuilder/RequestHandler

It turns out this type parameter was never necessary.  A builder only needs the reflexive second type parameter when you want to have a builder inheritance hierarchy where the descendant builders have methods that the ancestor builder doesn't.  In that case, the type param enables the ancestor builder's setter methods to automatically return the correct derived type, so that if you start with a derived builder, you can call a setter method inherited from an ancestor and then continue the chain with setters from the derived builder (e.g. new ContactResource.Builder().setCreationTime(now).setContactId(), which otherwise would have returned an EppResource.Builder from setCreationTime(), at which point the call to setContactId() would not compile).

Even then, it's not strictly necessary to use the type parameter, since you could instead just have each derived type override every inherited method to specify itself as the return type.  But that would be a lot of extra boilerplate and brittleness.

Anyway, in this case, there is a builder hierarchy, but RequestComponentBuilder specifies all the methods that we're ever going to want on our builders, so there's never any need to be able to call specific derived builder methods.  We only even need the individual builder classes so that Dagger can generate them separately for each component.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=148269178
This commit is contained in:
nickfelt 2017-02-22 14:31:15 -08:00 committed by Ben McIlwain
parent 16832323d0
commit 1e7fc4d64d
9 changed files with 17 additions and 21 deletions

View file

@ -22,8 +22,7 @@ import javax.inject.Inject;
import javax.inject.Provider;
/** Request handler for the tools module. */
public class ToolsRequestHandler
extends RequestHandler<ToolsRequestComponent, ToolsRequestComponent.Builder> {
public class ToolsRequestHandler extends RequestHandler<ToolsRequestComponent> {
@Inject ToolsRequestHandler(
Provider<ToolsRequestComponent.Builder> componentBuilderProvider,