All Downloads are FREE. Search and download functionalities are using the official Maven repository.

dagger.internal.codegen.binding.InjectBindingRegistry Maven / Gradle / Ivy

There is a newer version: 2.45-kim-rc1
Show newest version
/*
 * Copyright (C) 2017 The Dagger Authors.
 *
 * 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 dagger.internal.codegen.binding;

import androidx.room.compiler.processing.XConstructorElement;
import androidx.room.compiler.processing.XFieldElement;
import androidx.room.compiler.processing.XMethodElement;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import dagger.Component;
import dagger.Provides;
import dagger.internal.codegen.base.SourceFileGenerationException;
import dagger.internal.codegen.base.SourceFileGenerator;
import dagger.spi.model.Key;
import java.util.Optional;
import javax.inject.Inject;

/**
 * Maintains the collection of provision bindings from {@link Inject} constructors and members
 * injection bindings from {@link Inject} fields and methods known to the annotation processor. Note
 * that this registry does not handle any explicit bindings (those from {@link Provides}
 * methods, {@link Component} dependencies, etc.).
 */
public interface InjectBindingRegistry {
  /**
   * Returns a {@link ProvisionBinding} for {@code key}. If none has been registered yet, registers
   * one.
   */
  Optional getOrFindProvisionBinding(Key key);

  /**
   * Returns a {@link MembersInjectionBinding} for {@code key}. If none has been registered yet,
   * registers one, along with all necessary members injection bindings for superclasses.
   */
  Optional getOrFindMembersInjectionBinding(Key key);

  /**
   * Returns a {@link ProvisionBinding} for a {@link dagger.MembersInjector} of {@code key}. If none
   * has been registered yet, registers one.
   */
  Optional getOrFindMembersInjectorProvisionBinding(Key key);

  @CanIgnoreReturnValue
  Optional tryRegisterInjectConstructor(XConstructorElement constructorElement);

  @CanIgnoreReturnValue
  Optional tryRegisterInjectField(XFieldElement fieldElement);

  @CanIgnoreReturnValue
  Optional tryRegisterInjectMethod(XMethodElement methodElement);

  /**
   * This method ensures that sources for all registered {@link Binding bindings} (either explicitly
   * or implicitly via {@link #getOrFindMembersInjectionBinding} or {@link
   * #getOrFindProvisionBinding}) are generated.
   */
  void generateSourcesForRequiredBindings(
      SourceFileGenerator factoryGenerator,
      SourceFileGenerator membersInjectorGenerator)
      throws SourceFileGenerationException;
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy