google-nomulus/java/google/registry/request/RequestComponentBuilder.java
nickfelt 1e7fc4d64d 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
2017-02-27 11:12:07 -05:00

25 lines
866 B
Java

// Copyright 2017 The Nomulus Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package google.registry.request;
/**
* Builder interface for request components.
*
* @see RequestHandler
*/
public interface RequestComponentBuilder<C> {
RequestComponentBuilder<C> requestModule(RequestModule requestModule);
C build();
}