Customization - The type of the product customization.Product - The type of the values to be provided.public interface CustomizingProvider<Customization,Product>
CustomizingProvider provides customized values of the corresponding
product type.
Implementers may provide a new instance of the product each time
provide(Object) is called, but aren't requiered to do
so. An instance of the product that has already been returned once, may be
returned again for any or all following calls.
It is therefore not recommended to use Provides
for products that are stateful unless the internal state of a values doesn't
change the value. It is for example okay to use String as the product
type, although instances are stateful (String instances store their
hash value after it has been calculated for the first time and are therefore
technically stateful), but it is not okay to use Iterator as the
product type, because every call to Iterator.next() actually changes
the Iterator instance.
Providers are intended to be used in
situatuation, where a mechanism to retreive a value is more desirable than
having the value from the start. Theese are usually, but not necessarily,
situations where the following two conditions are met.
The second condition may only be true for the first call to
provide(Object) since Providers are allowed to cache and reuse the value.
CustomizingProducer,
Provider| Modifier and Type | Method and Description |
|---|---|
Product |
provide(Customization customization)
Provides a customized product.
|
Product provide(Customization customization) throws ProvisioningException
Implementers may provide a new instance of the product each time this method is called, but aren't requiered to do so. An instance of the product that has already been returned once, may be returned again in any or all following calls.
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
ProvisioningException.
customization - The customization to take into account.ProvisioningException - If the provisioning of the product failed.Copyright © 2015–2016 Markenwerk – Gesellschaft für markenbildende Maßnahmen mbH. All rights reserved.