- Type Parameters:
I- the type of the contextual instances thisFactorycreates and destroys
- All Known Implementing Classes:
Constant
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
A creator and destroyer of contextual instances of a particular type.
- Author:
- Laird Nelson
-
Field Summary
Fields inherited from interface org.microbean.bean.Aggregate
EMPTY_ASSIGNMENTS, EMPTY_DEPENDENCIES -
Method Summary
Modifier and TypeMethodDescriptionCreates a new contextual instance, possibly using the suppliedRequest, if it is non-null, to acquire its dependencies.default Optional<? extends ConstantDesc> Returns anOptionalcontaining the nominal descriptor for this instance, if one can be constructed, or an emptyOptionalif one cannot be constructed.default voiddefault booleandestroys()default IReturns the sole contextual instance of thisFactory's type, if there is one, ornullin the very common case that there is not.Methods inherited from interface org.microbean.bean.Aggregate
assign, dependencies
-
Method Details
-
create
Creates a new contextual instance, possibly using the suppliedRequest, if it is non-null, to acquire its dependencies.Implementations of this method must not call
singleton().Implementations of this method should consider calling
Creation.created(Object)on the suppliedRequestwith the contextual instance about to be returned.- Parameters:
r- aRequestresponsible for the demand for creation and used for acquiring any needed dependencies; may benullin early, uncommon bootstrap-like situations- Returns:
- a new contextual instance, or
null - Throws:
CreationException- if an error occurs- See Also:
-
singleton
Returns the sole contextual instance of thisFactory's type, if there is one, ornullin the very common case that there is not.The default implementation of this method returns
null.Overrides of this method should not call
create(Request).Overrides of this method must be idempotent and must return a determinate value.
- Returns:
- the sole contextual instance of this
Factory's type, or (commonly)null
-
destroys
-
destroy
-
describeConstable
Returns anOptionalcontaining the nominal descriptor for this instance, if one can be constructed, or an emptyOptionalif one cannot be constructed.The default implementation of this method returns an
Optionalthat contains a dynamic constant representing an invocation of the implementation's constructor that takes no arguments. The resolution of this dynamic constant is undefined if the implementation does not declare such a constructor.- Specified by:
describeConstablein interfaceConstable- Returns:
- an
Optionalcontaining the nominal descriptor for this instance, if one can be constructed, or an emptyOptionalif one cannot be constructed - Idempotency:
- This method is neither idempotent nor deterministic.
- Thread Safety:
- This method is safe for concurrent use by multiple threads.
-