Product - The type of the values to be produced.public interface Producer<Product>
Producer produces values of the corresponding product type.
Implementers must produce a new instance of the product, each time
produce() is called.
It is therefore okay to use Producers for products that are
stateful.
Producers are intended to be used in situatuation, where a
mechanism to retreive a value is more desirable than having the value from
the start and a Provider is not sufficient (i.e. because the product
is stateful).
Producers ar espacially helpful, if it is likely that
multiple instances of a stateful product will be used (i.e. multiple
Iterators over the same underlying data). Another use case
where a Producer may be more favourable than a {qlink Provider} is,
if it is not desirable to keep the value in memory.
Provider| Modifier and Type | Method and Description |
|---|---|
Product |
produce()
Produces a new product.
|
Product produce() throws ProductionException
Implementers must produce a new instance of the product, each time this method is called.
It lies in the responsibility of the caller, to handle unwanted
null-values by replacing them with a sensible default value or
throwing a NullPointerException.
Implementers should catch any exception and wrap them in a
ProductionException.
ProductionException - If the production of the product failed.Copyright © 2015–2016 Markenwerk – Gesellschaft für markenbildende Maßnahmen mbH. All rights reserved.