dagger.internal.codegen.binding.InjectBindingRegistry Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dagger-compiler Show documentation
Show all versions of dagger-compiler Show documentation
A fast dependency injector for Android and Java.
The 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.internal.codegen.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 an injection binding for {@code key}. If none has been registered yet, registers one.
*/
Optional getOrFindInjectionBinding(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 MembersInjectorBinding} for {@code key}. If none has been registered yet,
* registers one.
*/
Optional getOrFindMembersInjectorBinding(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 #getOrFindInjectionBinding}) are generated.
*/
void generateSourcesForRequiredBindings(
SourceFileGenerator factoryGenerator,
SourceFileGenerator membersInjectorGenerator)
throws SourceFileGenerationException;
}