Package com.google.inject.util
Class Modules
- java.lang.Object
-
- com.google.inject.util.Modules
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceModules.OverriddenModuleBuilderSee the EDSL example atoverride().
-
Field Summary
Fields Modifier and Type Field Description static ModuleEMPTY_MODULE
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static Modulecombine()Deprecated.this method call is effectively a no-op, just remove it.static Modulecombine(Module module)Deprecated.there's no need to "combine" one module; just install it directly.static Modulecombine(Module... modules)Returns a new module that installs all ofmodules.static Modulecombine(Iterable<? extends Module> modules)Returns a new module that installs all ofmodules.static ModuledisableCircularProxiesModule()Returns a module that will configure the injector to disable circular proxies.static Modules.OverriddenModuleBuilderoverride()Deprecated.there's no reason to useModules.override()without any arguments.static Modules.OverriddenModuleBuilderoverride(Module... modules)Returns a builder that creates a module that overlays override modules over the given modules.static Modules.OverriddenModuleBuilderoverride(Iterable<? extends Module> modules)Returns a builder that creates a module that overlays override modules over the given modules.static ModulerequireAtInjectOnConstructorsModule()Returns a module that will configure the injector to require @Injecton constructors.static ModulerequireExactBindingAnnotationsModule()Returns a module that will configure the injector to require an exactly matching binding annotation.static ModulerequireExplicitBindingsModule()Returns a module that will configure the injector to require explicit bindings.
-
-
-
Field Detail
-
EMPTY_MODULE
public static final Module EMPTY_MODULE
-
-
Method Detail
-
override
public static Modules.OverriddenModuleBuilder override(Module... modules)
Returns a builder that creates a module that overlays override modules over the given modules. If a key is bound in both sets of modules, only the binding from the override modules is kept. If a singlePrivateModuleis supplied or all elements are from a singlePrivateBinder, then this will overwrite the private bindings. Otherwise, private bindings will not be overwritten unless they are exposed. This can be used to replace the bindings of a production module with test bindings:Module functionalTestModule = Modules.override(new ProductionModule()).with(new TestModule());Prefer to write smaller modules that can be reused and tested without overrides.
- Parameters:
modules- the modules whose bindings are open to be overridden
-
override
@Deprecated public static Modules.OverriddenModuleBuilder override()
Deprecated.there's no reason to useModules.override()without any arguments.
-
override
public static Modules.OverriddenModuleBuilder override(Iterable<? extends Module> modules)
Returns a builder that creates a module that overlays override modules over the given modules. If a key is bound in both sets of modules, only the binding from the override modules is kept. If a singlePrivateModuleis supplied or all elements are from a singlePrivateBinder, then this will overwrite the private bindings. Otherwise, private bindings will not be overwritten unless they are exposed. This can be used to replace the bindings of a production module with test bindings:Module functionalTestModule = Modules.override(getProductionModules()).with(getTestModules());Prefer to write smaller modules that can be reused and tested without overrides.
- Parameters:
modules- the modules whose bindings are open to be overridden
-
combine
public static Module combine(Module... modules)
Returns a new module that installs all ofmodules.Although sometimes helpful, this method is rarely necessary. Most Guice APIs accept multiple arguments or (like
install()) can be called repeatedly. Where possible, external APIs that require a single module should similarly be adapted to permit multiple modules.
-
combine
@Deprecated public static Module combine(Module module)
Deprecated.there's no need to "combine" one module; just install it directly.
-
combine
@Deprecated public static Module combine()
Deprecated.this method call is effectively a no-op, just remove it.
-
combine
public static Module combine(Iterable<? extends Module> modules)
Returns a new module that installs all ofmodules.Although sometimes helpful, this method is rarely necessary. Most Guice APIs accept multiple arguments or (like
install()) can be called repeatedly. Where possible, external APIs that require a single module should similarly be adapted to permit multiple modules.
-
requireExplicitBindingsModule
public static Module requireExplicitBindingsModule()
Returns a module that will configure the injector to require explicit bindings.- Since:
- 4.2.3
-
requireAtInjectOnConstructorsModule
public static Module requireAtInjectOnConstructorsModule()
Returns a module that will configure the injector to require @Injecton constructors.- Since:
- 4.2.3
- See Also:
Binder.requireAtInjectOnConstructors()
-
requireExactBindingAnnotationsModule
public static Module requireExactBindingAnnotationsModule()
Returns a module that will configure the injector to require an exactly matching binding annotation.- Since:
- 4.2.3
- See Also:
Binder.requireExactBindingAnnotations()
-
disableCircularProxiesModule
public static Module disableCircularProxiesModule()
Returns a module that will configure the injector to disable circular proxies.- Since:
- 4.2.3
-
-