com.google.inject.spi
Class DefaultBindingTargetVisitor<T,V>

java.lang.Object
  extended by com.google.inject.spi.DefaultBindingTargetVisitor<T,V>
Type Parameters:
V - any type to be returned by the visit method. Use Void with return null if no return type is needed.
All Implemented Interfaces:
BindingTargetVisitor<T,V>

public abstract class DefaultBindingTargetVisitor<T,V>
extends Object
implements BindingTargetVisitor<T,V>

No-op visitor for subclassing. All interface methods simply delegate to visitOther(), returning its result.

Since:
2.0

Constructor Summary
DefaultBindingTargetVisitor()
           
 
Method Summary
 V visitConstructor(Constructor<? extends T> constructor, Set<InjectionPoint> injectionPoints)
          Visit a constructor binding.
 V visitConvertedConstant(T value)
          Visit a binding created from converting a bound instance to a new type.
 V visitInstance(T instance, Set<InjectionPoint> injectionPoints)
          Visit a instance binding.
 V visitKey(Key<? extends T> key)
          Visit a linked key binding.
protected  V visitOther()
           
 V visitProvider(Provider<? extends T> provider, Set<InjectionPoint> injectionPoints)
          Visit a provider instance binding.
 V visitProviderBinding(Key<?> provided)
          Visit a binding to a Provider that delegates to the binding for the provided type.
 V visitProviderKey(Key<? extends Provider<? extends T>> providerKey)
          Visit a provider key binding.
 V visitUntargetted()
          Visit an untargetted binding.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultBindingTargetVisitor

public DefaultBindingTargetVisitor()
Method Detail

visitOther

protected V visitOther()

visitInstance

public V visitInstance(T instance,
                       Set<InjectionPoint> injectionPoints)
Description copied from interface: BindingTargetVisitor
Visit a instance binding. The same instance is returned for every injection. This target is found in both module and injector bindings.

Specified by:
visitInstance in interface BindingTargetVisitor<T,V>
Parameters:
instance - the user-supplied value
injectionPoints - the field and method injection points of the instance, injected at injector-creation time only.

visitProvider

public V visitProvider(Provider<? extends T> provider,
                       Set<InjectionPoint> injectionPoints)
Description copied from interface: BindingTargetVisitor
Visit a provider instance binding. The provider's get method is invoked to resolve injections. This target is found in both module and injector bindings.

Specified by:
visitProvider in interface BindingTargetVisitor<T,V>
Parameters:
provider - the user-supplied, unscoped provider
injectionPoints - the field and method injection points of the provider, injected at injector-creation time only.

visitProviderKey

public V visitProviderKey(Key<? extends Provider<? extends T>> providerKey)
Description copied from interface: BindingTargetVisitor
Visit a provider key binding. To resolve injections, the provider injection is first resolved, then that provider's get method is invoked. This target is found in both module and injector bindings.

Specified by:
visitProviderKey in interface BindingTargetVisitor<T,V>
Parameters:
providerKey - the key used to resolve the provider's binding. That binding can be retrieved from an injector using Injector.getBinding(providerKey)

visitKey

public V visitKey(Key<? extends T> key)
Description copied from interface: BindingTargetVisitor
Visit a linked key binding. The other key's binding is used to resolve injections. This target is found in both module and injector bindings.

Specified by:
visitKey in interface BindingTargetVisitor<T,V>
Parameters:
key - the linked key used to resolve injections. That binding can be retrieved from an injector using Injector.getBinding(key)

visitUntargetted

public V visitUntargetted()
Description copied from interface: BindingTargetVisitor
Visit an untargetted binding. This target is found only on module bindings. It indicates that the injector should use its implicit binding strategies to resolve injections.

Specified by:
visitUntargetted in interface BindingTargetVisitor<T,V>

visitConstructor

public V visitConstructor(Constructor<? extends T> constructor,
                          Set<InjectionPoint> injectionPoints)
Description copied from interface: BindingTargetVisitor
Visit a constructor binding. To resolve injections, an instance is instantiated by invoking constructor. This target is found only on injector bindings.

Specified by:
visitConstructor in interface BindingTargetVisitor<T,V>
Parameters:
constructor - the annotated or default constructor that is invoked for creating values
injectionPoints - the constructor, field and method injection points to create and populate a new instance. The set contains exactly one constructor injection point.

visitConvertedConstant

public V visitConvertedConstant(T value)
Description copied from interface: BindingTargetVisitor
Visit a binding created from converting a bound instance to a new type. The source binding has the same binding annotation but a different type. This target is found only on injector bindings.

Specified by:
visitConvertedConstant in interface BindingTargetVisitor<T,V>
Parameters:
value - the converted value

visitProviderBinding

public V visitProviderBinding(Key<?> provided)
Description copied from interface: BindingTargetVisitor
Visit a binding to a Provider that delegates to the binding for the provided type. This target is found only on injector bindings.

Specified by:
visitProviderBinding in interface BindingTargetVisitor<T,V>
Parameters:
provided - the key whose binding is used to provide instances. That binding can be retrieved from an injector using Injector.getBinding(provided)


Copyright 2008 Google Inc. All Rights Reserved.