static class InternalInjectorCreator.ToolStageInjector extends java.lang.Object implements Injector
Injector exposed to users in Stage.TOOL.| Modifier and Type | Field and Description |
|---|---|
private Injector |
delegateInjector |
| Constructor and Description |
|---|
ToolStageInjector(Injector delegateInjector) |
| Modifier and Type | Method and Description |
|---|---|
Injector |
createChildInjector(java.lang.Iterable<? extends Module> modules)
Returns a new injector that inherits all state from this injector.
|
Injector |
createChildInjector(Module... modules)
Returns a new injector that inherits all state from this injector.
|
<T> java.util.List<Binding<T>> |
findBindingsByType(TypeLiteral<T> type)
Returns all explicit bindings for
type. |
java.util.Map<Key<?>,Binding<?>> |
getAllBindings()
Returns a snapshot of this injector's bindings, both explicit and
just-in-time.
|
<T> Binding<T> |
getBinding(java.lang.Class<T> type)
Returns the binding for the given type.
|
<T> Binding<T> |
getBinding(Key<T> key)
Returns the binding for the given injection key.
|
java.util.Map<Key<?>,Binding<?>> |
getBindings()
Returns this injector's explicit bindings.
|
<T> Binding<T> |
getExistingBinding(Key<T> key)
Returns the binding if it already exists, or null if does not exist.
|
<T> T |
getInstance(java.lang.Class<T> type)
Returns the appropriate instance for the given injection type; equivalent to
getProvider(type).get(). |
<T> T |
getInstance(Key<T> key)
Returns the appropriate instance for the given injection key; equivalent to
getProvider(key).get(). |
<T> MembersInjector<T> |
getMembersInjector(java.lang.Class<T> type)
Returns the members injector used to inject dependencies into methods and fields on instances
of the given type
T. |
<T> MembersInjector<T> |
getMembersInjector(TypeLiteral<T> typeLiteral)
Returns the members injector used to inject dependencies into methods and fields on instances
of the given type
T. |
Injector |
getParent()
Returns this injector's parent, or
null if this is a top-level injector. |
<T> Provider<T> |
getProvider(java.lang.Class<T> type)
Returns the provider used to obtain instances for the given type.
|
<T> Provider<T> |
getProvider(Key<T> key)
Returns the provider used to obtain instances for the given injection key.
|
java.util.Map<java.lang.Class<? extends java.lang.annotation.Annotation>,Scope> |
getScopeBindings()
Returns a map containing all scopes in the injector.
|
java.util.Set<TypeConverterBinding> |
getTypeConverterBindings()
Returns a set containing all type converter bindings in the injector.
|
void |
injectMembers(java.lang.Object o)
Injects dependencies into the fields and methods of
instance. |
private final Injector delegateInjector
ToolStageInjector(Injector delegateInjector)
public void injectMembers(java.lang.Object o)
Injectorinstance. Ignores the presence or
absence of an injectable constructor.
Whenever Guice creates an instance, it performs this injection automatically (after first performing constructor injection), so if you're able to let Guice create all your objects for you, you'll never need to use this method.
injectMembers in interface Injectoro - to inject members onfor a preferred alternative that supports checks before
run timepublic java.util.Map<Key<?>,Binding<?>> getBindings()
InjectorThe returned map does not include bindings inherited from a parent
injector, should one exist. The returned map is guaranteed to iterate (for example, with
its Map.entrySet() iterator) in the order of insertion. In other words, the order in
which bindings appear in user Modules.
This method is part of the Guice SPI and is intended for use by tools and extensions.
getBindings in interface Injectorpublic java.util.Map<Key<?>,Binding<?>> getAllBindings()
InjectorgetAllBindings() was invoked. Subsequent calls may return a map with
additional just-in-time bindings.
The returned map does not include bindings inherited from a parent
injector, should one exist.
This method is part of the Guice SPI and is intended for use by tools and extensions.
getAllBindings in interface Injectorpublic <T> Binding<T> getBinding(Key<T> key)
InjectorThis method is part of the Guice SPI and is intended for use by tools and extensions.
getBinding in interface Injectorpublic <T> Binding<T> getBinding(java.lang.Class<T> type)
InjectorThis method is part of the Guice SPI and is intended for use by tools and extensions.
getBinding in interface Injectorpublic <T> Binding<T> getExistingBinding(Key<T> key)
InjectorInjector.getBinding(Key), this does not attempt to create just-in-time bindings
for keys that aren't bound.
This method is part of the Guice SPI and is intended for use by tools and extensions.
getExistingBinding in interface Injectorpublic <T> java.util.List<Binding<T>> findBindingsByType(TypeLiteral<T> type)
Injectortype.
This method is part of the Guice SPI and is intended for use by tools and extensions.
findBindingsByType in interface Injectorpublic Injector getParent()
Injectornull if this is a top-level injector.public Injector createChildInjector(java.lang.Iterable<? extends Module> modules)
InjectorJust-in-time bindings created for child injectors will be created in an ancestor injector whenever possible. This allows for scoped instances to be shared between injectors. Use explicit bindings to prevent bindings from being shared with the parent injector. Optional injections in just-in-time bindings (created in the parent injector) may be silently ignored if the optional dependencies are from the child injector.
No key may be bound by both an injector and one of its ancestors. This includes just-in-time
bindings. The lone exception is the key for Injector.class, which is bound by each
injector to itself.
createChildInjector in interface Injectorpublic Injector createChildInjector(Module... modules)
InjectorJust-in-time bindings created for child injectors will be created in an ancestor injector whenever possible. This allows for scoped instances to be shared between injectors. Use explicit bindings to prevent bindings from being shared with the parent injector.
No key may be bound by both an injector and one of its ancestors. This includes just-in-time
bindings. The lone exception is the key for Injector.class, which is bound by each
injector to itself.
createChildInjector in interface Injectorpublic java.util.Map<java.lang.Class<? extends java.lang.annotation.Annotation>,Scope> getScopeBindings()
InjectorSingleton.class, and the values are scope instances, such as Scopes.SINGLETON. The returned map is immutable.
This method is part of the Guice SPI and is intended for use by tools and extensions.
getScopeBindings in interface Injectorpublic java.util.Set<TypeConverterBinding> getTypeConverterBindings()
InjectorThis method is part of the Guice SPI and is intended for use by tools and extensions.
getTypeConverterBindings in interface Injectorpublic <T> Provider<T> getProvider(Key<T> key)
InjectorgetProvider in interface Injectorfor an alternative that offers up front error detectionpublic <T> Provider<T> getProvider(java.lang.Class<T> type)
InjectorgetProvider in interface Injectorfor an alternative that offers up front error detectionpublic <T> MembersInjector<T> getMembersInjector(TypeLiteral<T> typeLiteral)
InjectorT.getMembersInjector in interface InjectortypeLiteral - type to get members injector forfor an alternative that offers up front error
detectionpublic <T> MembersInjector<T> getMembersInjector(java.lang.Class<T> type)
InjectorT. When feasible, use Binder.getMembersInjector(TypeLiteral)
instead to get increased up front error detection.getMembersInjector in interface Injectortype - type to get members injector forfor an alternative that offers up front error
detectionpublic <T> T getInstance(Key<T> key)
InjectorgetProvider(key).get(). When feasible, avoid using this method, in favor of having Guice
inject your dependencies ahead of time.getInstance in interface Injectorpublic <T> T getInstance(java.lang.Class<T> type)
InjectorgetProvider(type).get(). When feasible, avoid using this method, in favor of having Guice
inject your dependencies ahead of time.getInstance in interface Injector