mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 07:57:13 +02:00
Migrate @Provides methods to @Binds methods where possible.
@Binds is a much more efficient way to delegate one binding to another in that: * The @Binds method does not need to be invoked * It does not generate an additional Provider implementation * An additional Provider does does not need to be instantiated Future changes to Dagger's component processor will add even further benefits. More information: [] ATTENTION REVIEWERS: This migration is being done with global approval. Per-project approval is not required. Tested: TAP train for global presubmit queue [] ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=125980758
This commit is contained in:
parent
a4091594d0
commit
a47cc2a85c
5 changed files with 20 additions and 26 deletions
|
@ -27,6 +27,7 @@ import static google.registry.request.RequestParameters.extractSetOfParameters;
|
|||
import com.google.appengine.api.taskqueue.Queue;
|
||||
import com.google.appengine.api.taskqueue.QueueFactory;
|
||||
|
||||
import dagger.Binds;
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
|
@ -42,13 +43,11 @@ import javax.servlet.http.HttpServletRequest;
|
|||
|
||||
/** Dagger module for the dns package. */
|
||||
@Module
|
||||
public final class DnsModule {
|
||||
public abstract class DnsModule {
|
||||
|
||||
@Provides
|
||||
@Binds
|
||||
@DnsWriterZone
|
||||
static String provideZoneName(@Parameter(RequestParameters.PARAM_TLD) String tld) {
|
||||
return tld;
|
||||
}
|
||||
abstract String provideZoneName(@Parameter(RequestParameters.PARAM_TLD) String tld);
|
||||
|
||||
@Provides
|
||||
@Named(DNS_PULL_QUEUE_NAME)
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
package google.registry.dns.writer.dnsupdate;
|
||||
|
||||
import dagger.Binds;
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
|
@ -23,12 +24,10 @@ import javax.net.SocketFactory;
|
|||
|
||||
/** Dagger module that provides a DnsUpdateWriter. */
|
||||
@Module
|
||||
public final class DnsUpdateWriterModule {
|
||||
public abstract class DnsUpdateWriterModule {
|
||||
|
||||
@Provides
|
||||
static DnsWriter provideDnsWriter(DnsUpdateWriter dnsWriter) {
|
||||
return dnsWriter;
|
||||
}
|
||||
@Binds
|
||||
abstract DnsWriter provideDnsWriter(DnsUpdateWriter dnsWriter);
|
||||
|
||||
@Provides
|
||||
static SocketFactory provideSocketFactory() {
|
||||
|
|
|
@ -14,15 +14,13 @@
|
|||
|
||||
package google.registry.groups;
|
||||
|
||||
import dagger.Binds;
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
/** Dagger module for groups package. */
|
||||
@Module
|
||||
public final class GroupsModule {
|
||||
public abstract class GroupsModule {
|
||||
|
||||
@Provides
|
||||
static GroupsConnection provideGroupsConnection(DirectoryGroupsConnection connection) {
|
||||
return connection;
|
||||
}
|
||||
@Binds
|
||||
abstract GroupsConnection provideGroupsConnection(DirectoryGroupsConnection connection);
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ import com.google.appengine.api.urlfetch.URLFetchServiceFactory;
|
|||
import com.google.appengine.api.users.UserService;
|
||||
import com.google.appengine.api.users.UserServiceFactory;
|
||||
|
||||
import dagger.Binds;
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
|
@ -138,11 +139,9 @@ public final class Modules {
|
|||
* <p>You must also use the {@link AppIdentityCredential} module.
|
||||
*/
|
||||
@Module
|
||||
public static final class UseAppIdentityCredentialForGoogleApisModule {
|
||||
@Provides
|
||||
static HttpRequestInitializer provideHttpRequestInitializer(AppIdentityCredential credential) {
|
||||
return credential;
|
||||
}
|
||||
public abstract static class UseAppIdentityCredentialForGoogleApisModule {
|
||||
@Binds
|
||||
abstract HttpRequestInitializer provideHttpRequestInitializer(AppIdentityCredential credential);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
package google.registry.tools;
|
||||
|
||||
import dagger.Binds;
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
|
@ -24,17 +25,15 @@ import java.util.Random;
|
|||
|
||||
/** Dagger module for Registry Tool. */
|
||||
@Module
|
||||
final class RegistryToolModule {
|
||||
abstract class RegistryToolModule {
|
||||
|
||||
@Provides
|
||||
static RegistryToolEnvironment provideRegistryToolEnvironment() {
|
||||
return RegistryToolEnvironment.get();
|
||||
}
|
||||
|
||||
@Provides
|
||||
static PasswordGenerator providePasswordGenerator(RandomPasswordGenerator passwordGenerator) {
|
||||
return passwordGenerator;
|
||||
}
|
||||
@Binds
|
||||
abstract PasswordGenerator providePasswordGenerator(RandomPasswordGenerator passwordGenerator);
|
||||
|
||||
@Provides
|
||||
static Random provideRandom() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue