Interface Factory<I>
-
Field Summary
Fields inherited from interface org.microbean.bean.Aggregate
EMPTY_ASSIGNMENTS, EMPTY_DEPENDENCIES
-
Method Summary
Modifier and TypeMethodDescriptionReturns a (normally new) contextual instance, which may benull
.default Optional
<? extends ConstantDesc> Returns anOptional
containing the nominal descriptor for this instance, if one can be constructed, or an emptyOptional
if one cannot be constructed.default void
destroy
(I i, Destruction creation) Destroys the supplied contextual instance.default boolean
destroys()
default I
Returns the sole contextual instance of thisFactory
's type, if there is one, ornull
in the very common case that there is not.Methods inherited from interface org.microbean.bean.Aggregate
assign, dependencies
-
Method Details
-
create
-
describeConstable
Returns anOptional
containing the nominal descriptor for this instance, if one can be constructed, or an emptyOptional
if one cannot be constructed.The default implementation of this method returns an
Optional
that 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:
describeConstable
in interfaceConstable
- Returns:
- an
Optional
containing the nominal descriptor for this instance, if one can be constructed, or an emptyOptional
if one cannot be constructed - Idempotency:
- This method is neither idempotent nor deterministic.
- Thread Safety:
- This method is safe for concurrent use by multiple threads.
-
destroy
Destroys the supplied contextual instance.The default implementation of this method closes the supplied contextual instance if it is an instance of
AutoCloseable
, and closes the suppliedDestruction
if it is non-null
.- Parameters:
i
- the contextual instance to destroy; may benull
in which case no action must be takencreation
- the object supplied to thecreate(Creation)
method represented here as aDestruction
; may benull
; must have an idempotentclose()
method- See Also:
-
destroys
-
singleton
Returns the sole contextual instance of thisFactory
's type, if there is one, ornull
in the very common case that there is not.The default implementation of this method returns
null
.Overrides of this method should not call
create(Creation)
.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
-