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.
Producers are used to implement Factory instances' create(Request)
and destroy(Object, Request) methods. Values returned from the produce(Request) method are often supplied to Initializers.
- Author:
- Laird Nelson
- See Also:
-
Field Summary
Fields inherited from interface org.microbean.bean.Aggregate
EMPTY_ASSIGNMENTS, EMPTY_DEPENDENCIES -
Method Summary
Modifier and TypeMethodDescriptiondefault voidDisposes 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 IProduces 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
iis an instance ofAutoCloseable, and, if so, callsclose()on it, throwing any resulting exception as aDestructionException.- Parameters:
i- a contextual instance produced by thisProducer; may benullr- theRequestthat was present at production time; must not benull- Throws:
NullPointerException- ifrisnullDestructionException- ifiis anAutoCloseableinstance, 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- ifrisnull- 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- aSequencedSetofAssignments thisProducerneeds to create the contextual instance; must not benull- Returns:
- a new contextual instance, or
null - Throws:
NullPointerException- ifdependentContextualReferencesisnull
-