Module net.finmath.lib
Class ProductFactoryCascade<T extends ProductDescriptor>
java.lang.Object
net.finmath.modelling.productfactory.ProductFactoryCascade<T>
- Type Parameters:
T
- The base class of the product descriptors which can be handled by thisProductFactory
.
- All Implemented Interfaces:
ProductFactory<T>
public class ProductFactoryCascade<T extends ProductDescriptor>
extends Object
implements ProductFactory<T>
Implements a product factory based on a cascade of given factories. When invoking
getProductFromDescriptor(ProductDescriptor productDescriptor)
the cascade will query all its individual factories until one builds the product. When querying the factories the cascade will start at index 0.- Version:
- 1.0
- Author:
- Christian Fries, Roland Bachl
-
Constructor Summary
ConstructorsConstructorDescriptionConstruct an empty factory cascade.ProductFactoryCascade(List<ProductFactory<? extends T>> factories)
Construct a factory cascade from an ordered list of product factories. -
Method Summary
Modifier and TypeMethodDescriptionaddFactoryAfter(ProductFactory<? extends T> factory)
Add a given factory to the list of factories at the END.addFactoryBefore(ProductFactory<? extends T> factory)
Add a given factory to the list of factories at the BEGINNING.DescribedProduct<? extends T>
getProductFromDescriptor(ProductDescriptor productDescriptor)
Constructs the product from a given product descriptor.
-
Constructor Details
-
ProductFactoryCascade
public ProductFactoryCascade()Construct an empty factory cascade. This will build no products until amended. -
ProductFactoryCascade
Construct a factory cascade from an ordered list of product factories. When querying the factories the cascade will start at index 0.- Parameters:
factories
- A list of product factories, i.e. object implementingProductFactory
for the product descriptorT
.
-
-
Method Details
-
addFactoryBefore
Add a given factory to the list of factories at the BEGINNING.- Parameters:
factory
- The factory to be added.- Returns:
- Cascade with amended factory list.
-
addFactoryAfter
Add a given factory to the list of factories at the END.- Parameters:
factory
- The factory to be added.- Returns:
- Cascade with amended factory list.
-
getProductFromDescriptor
Description copied from interface:ProductFactory
Constructs the product from a given product descriptor.- Specified by:
getProductFromDescriptor
in interfaceProductFactory<T extends ProductDescriptor>
- Parameters:
productDescriptor
- A product descriptor.- Returns:
- An instance of the product describable by this descriptor.
-