1 /** 2 * Copyright (C) 2008 Google Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.google.inject.spi; 18 19 /** 20 * Visits each of the strategies used to find an instance to satisfy an injection. 21 * 22 * @param <V> any type to be returned by the visit method. Use {@link Void} with 23 * {@code return null} if no return type is needed. 24 * @since 2.0 25 */ 26 public interface BindingTargetVisitor<T, V> { 27 28 /** 29 * Visit a instance binding. The same instance is returned for every injection. This target is 30 * found in both module and injector bindings. 31 */ visit(InstanceBinding<? extends T> binding)32 V visit(InstanceBinding<? extends T> binding); 33 34 /** 35 * Visit a provider instance binding. The provider's {@code get} method is invoked to resolve 36 * injections. This target is found in both module and injector bindings. 37 */ visit(ProviderInstanceBinding<? extends T> binding)38 V visit(ProviderInstanceBinding<? extends T> binding); 39 40 /** 41 * Visit a provider key binding. To resolve injections, the provider key is first resolved, then 42 * that provider's {@code get} method is invoked. This target is found in both module and injector 43 * bindings. 44 */ visit(ProviderKeyBinding<? extends T> binding)45 V visit(ProviderKeyBinding<? extends T> binding); 46 47 /** 48 * Visit a linked key binding. The other key's binding is used to resolve injections. This 49 * target is found in both module and injector bindings. 50 */ visit(LinkedKeyBinding<? extends T> binding)51 V visit(LinkedKeyBinding<? extends T> binding); 52 53 /** 54 * Visit a binding to a key exposed from an enclosed private environment. This target is only 55 * found in injector bindings. 56 */ visit(ExposedBinding<? extends T> binding)57 V visit(ExposedBinding<? extends T> binding); 58 59 /** 60 * Visit an untargetted binding. This target is found only on module bindings. It indicates 61 * that the injector should use its implicit binding strategies to resolve injections. 62 */ visit(UntargettedBinding<? extends T> binding)63 V visit(UntargettedBinding<? extends T> binding); 64 65 /** 66 * Visit a constructor binding. To resolve injections, an instance is instantiated by invoking 67 * {@code constructor}. This target is found only on injector bindings. 68 */ visit(ConstructorBinding<? extends T> binding)69 V visit(ConstructorBinding<? extends T> binding); 70 71 /** 72 * Visit a binding created from converting a bound instance to a new type. The source binding 73 * has the same binding annotation but a different type. This target is found only on injector 74 * bindings. 75 */ visit(ConvertedConstantBinding<? extends T> binding)76 V visit(ConvertedConstantBinding<? extends T> binding); 77 78 /** 79 * Visit a binding to a {@link com.google.inject.Provider} that delegates to the binding for the 80 * provided type. This target is found only on injector bindings. 81 */ visit(ProviderBinding<? extends T> binding)82 V visit(ProviderBinding<? extends T> binding); 83 } 84