Class ProductFactoryCascade<T extends ProductDescriptor>

  • 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 Detail

      • 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 Detail

      • 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.