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

@ -194,7 +194,7 @@ public final class RequestHandlerTest {
}
/** Fake Builder for the fake component above to satisfy RequestHandler expectations. */
public abstract class Builder implements RequestComponentBuilder<Component, Builder> {
public abstract class Builder implements RequestComponentBuilder<Component> {
@Override
public Builder requestModule(RequestModule requestModule) {
component.setRequestModule(requestModule);
@ -222,7 +222,7 @@ public final class RequestHandlerTest {
private final Component component = new Component();
private final StringWriter httpOutput = new StringWriter();
private RequestHandler<Component, Builder> handler;
private RequestHandler<Component> handler;
private AuthResult providedAuthResult = null;
private final User testUser = new User("test@example.com", "test@example.com");
private RequestAuthenticator requestAuthenticator;
@ -244,7 +244,7 @@ public final class RequestHandlerTest {
new LegacyAuthenticationMechanism(userService));
// Initialize here, not inline, so that we pick up the mocked UserService.
handler = RequestHandler.<Component, Builder>createForTest(
handler = RequestHandler.<Component>createForTest(
Component.class,
Providers.<Builder>of(new Builder() {
@Override