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 this ProductFactory.
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 Details

    • ProductFactoryCascade

      public ProductFactoryCascade()
      Construct an empty factory cascade. This will build no products until amended.
    • ProductFactoryCascade

      public ProductFactoryCascade(List<ProductFactory<? extends T>> factories)
      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 implementing ProductFactory for the product descriptor T.
  • Method Details

    • addFactoryBefore

      public ProductFactoryCascade<T> addFactoryBefore(ProductFactory<? extends T> factory)
      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

      public ProductFactoryCascade<T> addFactoryAfter(ProductFactory<? extends T> factory)
      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

      public DescribedProduct<? extends T> getProductFromDescriptor(ProductDescriptor productDescriptor)
      Description copied from interface: ProductFactory
      Constructs the product from a given product descriptor.
      Specified by:
      getProductFromDescriptor in interface ProductFactory<T extends ProductDescriptor>
      Parameters:
      productDescriptor - A product descriptor.
      Returns:
      An instance of the product describable by this descriptor.