Interface Scope
- All Known Implementing Classes:
ScopedValueScope
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Controls the lifecycle and sharing of instances produced by a
Binding. A Scope
wraps an unscoped ValueBinding and returns a new Binding that applies the scope's
caching or sharing strategy.
Register custom scopes via InjectionFramework.bindScope(Class, Scope).
The built-in implementation is ScopedValueScope, which uses a ScopedValue
to cache one instance per structured scope invocation.
- Since:
- Apr-2026
- Author:
- reed.vonredwitz
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionBinding<?> scope(ValueBinding<?> binding) Wraps the given unscopedValueBindingin a scopedBinding.
-
Method Details
-
scope
Wraps the given unscopedValueBindingin a scopedBinding. The returned binding may cache, share, or re-create instances according to the scope's strategy.The signature uses wildcards so that implementations may be expressed as lambdas. The framework guarantees that the returned
Bindingproduces values that are assignment-compatible with the type represented byBinding.dependency().- Parameters:
binding- the unscopedValueBindingwhoseValueBinding.value()creates a fresh instance on each call- Returns:
- a scoped
Bindingimplementing this scope's instance lifecycle
-