Package com.google.inject.internal
Class Indexer
java.lang.Object
com.google.inject.spi.DefaultBindingTargetVisitor<Object,Indexer.IndexedBinding>
com.google.inject.internal.Indexer
- All Implemented Interfaces:
BindingScopingVisitor<Object>
,BindingTargetVisitor<Object,
Indexer.IndexedBinding>
class Indexer
extends DefaultBindingTargetVisitor<Object,Indexer.IndexedBinding>
implements BindingScopingVisitor<Object>
Visits bindings to return a
IndexedBinding
that can be used to emulate the binding
deduplication that Guice internally performs.
Note: simply using equals/hashCode on the BindingImpls doesn't work because they all have
unique annotations. This works around that by reimplementing equality semantics that ignores
Element.uniqueId()
. A better solution might be to introduce the idea of an 'anonymous'
binding to guice, that might support this usecase directly.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static enum
(package private) static class
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) boolean
isIndexable
(Binding<?> binding) private Object
visit
(ConstructorBinding<? extends Object> binding) Visit a constructor binding.visit
(ConvertedConstantBinding<? extends Object> binding) Visit a binding created from converting a bound instance to a new type.visit
(ExposedBinding<? extends Object> binding) Visit a binding to a key exposed from an enclosed private environment.visit
(InstanceBinding<? extends Object> binding) Visit a instance binding.visit
(LinkedKeyBinding<? extends Object> binding) Visit a linked key binding.visit
(ProviderBinding<? extends Object> binding) Visit a binding to aProvider
that delegates to the binding for the provided type.visit
(ProviderInstanceBinding<? extends Object> binding) Visit a provider instance binding.visit
(ProviderKeyBinding<? extends Object> binding) Visit a provider key binding.visit
(UntargettedBinding<? extends Object> binding) Visit an untargetted binding.Visit an eager singleton or single instance.Visit an unspecified or unscoped strategy.visitScope
(Scope scope) Visit a scope instance.visitScopeAnnotation
(Class<? extends Annotation> scopeAnnotation) Visit a scope annotation.Methods inherited from class com.google.inject.spi.DefaultBindingTargetVisitor
visitOther
-
Field Details
-
injector
-
EAGER_SINGLETON
-
-
Constructor Details
-
Indexer
Indexer(Injector injector)
-
-
Method Details
-
isIndexable
-
scope
-
visit
Description copied from interface:BindingTargetVisitor
Visit a constructor binding. To resolve injections, an instance is instantiated by invokingconstructor
. This target is found only on injector bindings.- Specified by:
visit
in interfaceBindingTargetVisitor<Object,
Indexer.IndexedBinding> - Overrides:
visit
in classDefaultBindingTargetVisitor<Object,
Indexer.IndexedBinding>
-
visit
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:
visit
in interfaceBindingTargetVisitor<Object,
Indexer.IndexedBinding> - Overrides:
visit
in classDefaultBindingTargetVisitor<Object,
Indexer.IndexedBinding>
-
visit
Description copied from interface:BindingTargetVisitor
Visit a binding to a key exposed from an enclosed private environment. This target is only found in injector bindings.- Specified by:
visit
in interfaceBindingTargetVisitor<Object,
Indexer.IndexedBinding> - Overrides:
visit
in classDefaultBindingTargetVisitor<Object,
Indexer.IndexedBinding>
-
visit
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:
visit
in interfaceBindingTargetVisitor<Object,
Indexer.IndexedBinding> - Overrides:
visit
in classDefaultBindingTargetVisitor<Object,
Indexer.IndexedBinding>
-
visit
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:
visit
in interfaceBindingTargetVisitor<Object,
Indexer.IndexedBinding> - Overrides:
visit
in classDefaultBindingTargetVisitor<Object,
Indexer.IndexedBinding>
-
visit
Description copied from interface:BindingTargetVisitor
Visit a binding to aProvider
that delegates to the binding for the provided type. This target is found only on injector bindings.- Specified by:
visit
in interfaceBindingTargetVisitor<Object,
Indexer.IndexedBinding> - Overrides:
visit
in classDefaultBindingTargetVisitor<Object,
Indexer.IndexedBinding>
-
visit
Description copied from interface:BindingTargetVisitor
Visit a provider instance binding. The provider'sget
method is invoked to resolve injections. This target is found in both module and injector bindings.- Specified by:
visit
in interfaceBindingTargetVisitor<Object,
Indexer.IndexedBinding> - Overrides:
visit
in classDefaultBindingTargetVisitor<Object,
Indexer.IndexedBinding>
-
visit
Description copied from interface:BindingTargetVisitor
Visit a provider key binding. To resolve injections, the provider key is first resolved, then that provider'sget
method is invoked. This target is found in both module and injector bindings.- Specified by:
visit
in interfaceBindingTargetVisitor<Object,
Indexer.IndexedBinding> - Overrides:
visit
in classDefaultBindingTargetVisitor<Object,
Indexer.IndexedBinding>
-
visit
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:
visit
in interfaceBindingTargetVisitor<Object,
Indexer.IndexedBinding> - Overrides:
visit
in classDefaultBindingTargetVisitor<Object,
Indexer.IndexedBinding>
-
visitEagerSingleton
Description copied from interface:BindingScopingVisitor
Visit an eager singleton or single instance. This scope strategy is found on both module and injector bindings.- Specified by:
visitEagerSingleton
in interfaceBindingScopingVisitor<Object>
-
visitNoScoping
Description copied from interface:BindingScopingVisitor
Visit an unspecified or unscoped strategy. On a module, this strategy indicates that the injector should use scoping annotations to find a scope. On an injector, it indicates that no scope is applied to the binding. An unscoped binding will behave like a scoped one when it is linked to a scoped binding.- Specified by:
visitNoScoping
in interfaceBindingScopingVisitor<Object>
-
visitScope
Description copied from interface:BindingScopingVisitor
Visit a scope instance. This scope strategy is found on both module and injector bindings.- Specified by:
visitScope
in interfaceBindingScopingVisitor<Object>
-
visitScopeAnnotation
Description copied from interface:BindingScopingVisitor
Visit a scope annotation. This scope strategy is found only on module bindings. The instance that implements this scope is registered byBinder.bindScope()
.- Specified by:
visitScopeAnnotation
in interfaceBindingScopingVisitor<Object>
-