Class ProvidesResolver
java.lang.Object
build.codemodel.dependency.injection.ProvidesResolver
A
Resolver of values produced by Provides-annotated methods on a provider object.
At construction, the provider object's type descriptor hierarchy is scanned via the
InjectionFramework for non-static, non-abstract, non-void, no-arg methods annotated with
Provides. Each such method's return type is registered as a resolvable type.
At resolve time, the matching method is invoked and its return value is wrapped in a ValueBinding.
Each call to resolve(Dependency) invokes the Provides method afresh, giving factory-per-resolution
semantics (analogous to an unscoped binding in Dagger/Guice). If singleton semantics are required, the
provider object should memoize the value itself.
- Author:
- reed.vonredwitz
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic ProvidesResolverof(Object providerObject, InjectionFramework framework) Creates aProvidesResolverfor the specified provider object.resolve(Dependency dependency) Attempts to resolve a value for the type specified by theDependency.
-
Method Details
-
resolve
Description copied from interface:ResolverAttempts to resolve a value for the type specified by theDependency.- Specified by:
resolvein interfaceResolver<Object>- Parameters:
dependency- theDependency- Returns:
- the
Optionalvalue if resolvable,Optional.empty()otherwise
-
of
Creates aProvidesResolverfor the specified provider object.- Parameters:
providerObject- the provider objectframework- theInjectionFramework- Returns:
- a new
ProvidesResolver
-