Top Description Methods
com.google.inject.spi

public Interface ProviderWithExtensionVisitor<T>

extends Provider<T>
Known Direct Implementers
com.google.inject.internal.ProviderMethod, com.google.inject.internal.RealMapBinder.ExtensionRealMapProvider, com.google.inject.internal.RealMultibinder.RealMultibinderProvider, com.google.inject.internal.RealOptionalBinder.JavaOptionalProvider, com.google.inject.internal.RealOptionalBinder.RealOptionalKeyProvider
Imports
com.google.inject.Binding, .Provider

A Provider that is part of an extension which supports a custom BindingTargetVisitor.

When an extension binds a provider instance, the provider can implement this interface to allow users using the Binding#acceptTargetVisitor(BindingTargetVisitor) method to visit a custom visitor designed for that extension. A typical implementation within the extension would look like

<V, B> V acceptExtensionVisitor(
   BindingTargetVisitor<B, V> visitor, ProviderInstanceBinding<? extends B> binding) {
  if(visitor instanceof MyCustomExtensionVisitor) {
    return ((MyCustomExtensionVisitor<B, V>)visitor)
       .visitCustomExtension(customProperties, binding);
  } else {
    return visitor.visit(binding);
  }
}
'MyCustomExtensionVisitor' in the example above would be an interface the extension provides that users can implement in order to be notified of custom extension information. These visitor interfaces must extend from BindingTargetVisitor.
Author
[email protected] (Sam Berlin)
Since
3.0

Method Summary

Modifier and TypeMethod and Description
public <B, V> V
acceptExtensionVisitor(BindingTargetVisitor<B, V> visitor, ProviderInstanceBinding<? extends B> binding)

Instructs the extension determine if the visitor is an instance of a custom extension visitor, and if so, visit it using that method.

Inherited from com.google.inject.Provider:
get

Method Detail

acceptExtensionVisitorback to summary
public <B, V> V acceptExtensionVisitor(BindingTargetVisitor<B, V> visitor, ProviderInstanceBinding<? extends B> binding)

Instructs the extension determine if the visitor is an instance of a custom extension visitor, and if so, visit it using that method. If the visitor is not an instance of the custom extension visitor, this method MUST call visitor.visit(binding).

Due to issues with generics, the type parameters of this method do not relate to the type of the provider. In practice, the 'B' type will always be a supertype of 'T'.