Scopes an internal factory.
(
Key<T> key,
InjectorImpl injector,
InternalFactory<? extends T> creator,
Object source,
Scoping scoping)
| 281 | |
| 282 | /** Scopes an internal factory. */ |
| 283 | static <T> InternalFactory<? extends T> scope( |
| 284 | Key<T> key, |
| 285 | InjectorImpl injector, |
| 286 | InternalFactory<? extends T> creator, |
| 287 | Object source, |
| 288 | Scoping scoping) { |
| 289 | |
| 290 | if (scoping.isNoScope()) { |
| 291 | return creator; |
| 292 | } |
| 293 | |
| 294 | Scope scope = scoping.getScopeInstance(); |
| 295 | |
| 296 | // NOTE: SingletonScope relies on the fact that we are passing a |
| 297 | // ProviderToInternalFactoryAdapter here. If you change the type make sure to update |
| 298 | // SingletonScope as well. |
| 299 | Provider<T> scoped = |
| 300 | scope.scope(key, new ProviderToInternalFactoryAdapter<T>(injector, creator)); |
| 301 | return new InternalFactoryToProviderAdapter<T>(scoped, source); |
| 302 | } |
| 303 | |
| 304 | /** |
| 305 | * Replaces annotation scopes with instance scopes using the Injector's annotation-to-instance |
no test coverage detected