Interface Producer<I>
- Type Parameters:
I
- the type of contextual instance
- All Superinterfaces:
Aggregate
- All Known Implementing Classes:
InterceptingProducer
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
An interface whose implementations produce possibly uninitialized contextual
instances.
Producer
s are used to implement Factory
instances' create(Request)
and destroy(Object, Request)
methods. Values returned from the produce(Request)
method are often supplied to Initializer
s.
- Author:
- Laird Nelson
- See Also:
-
Field Summary
Fields inherited from interface org.microbean.bean.Aggregate
EMPTY_ASSIGNMENTS, EMPTY_DEPENDENCIES
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
Disposes of the supplied contextual instance.produce
(SequencedSet<? extends Assignment<?>> assignments) Produces a new contextual instance and returns it, possibly (often) making use of the supplied, dependent, contextual references.default I
Produces a new contextual instance and returns it by calling theproduce(SequencedSet)
method with the return value of an invocation of theAggregate.assign(Request)
method with the suppliedRequest
.Methods inherited from interface org.microbean.bean.Aggregate
assign, dependencies
-
Method Details
-
dispose
Disposes of the supplied contextual instance.The default implementation of this method checks to see if
i
is an instance ofAutoCloseable
, and, if so, callsclose()
on it, throwing any resulting exception as aDestructionException
.- Parameters:
i
- a contextual instance produced by thisProducer
; may benull
r
- theRequest
that was present at production time; must not benull
- Throws:
NullPointerException
- ifr
isnull
DestructionException
- ifi
is anAutoCloseable
instance, and if itsclose()
method throws a checked exception
-
produce
Produces a new contextual instance and returns it by calling theproduce(SequencedSet)
method with the return value of an invocation of theAggregate.assign(Request)
method with the suppliedRequest
.- Parameters:
r
- aRequest
; must not benull
- Returns:
- a new contextual instance, or
null
- Throws:
NullPointerException
- ifr
isnull
- See Also:
-
produce
Produces a new contextual instance and returns it, possibly (often) making use of the supplied, dependent, contextual references.Implementations of this method must not call
produce(Request)
or an infinite loop may result.- Parameters:
assignments
- aSequencedSet
ofAssignment
s thisProducer
needs to create the contextual instance; must not benull
- Returns:
- a new contextual instance, or
null
- Throws:
NullPointerException
- ifdependentContextualReferences
isnull
-