Class Storage


  • public class Storage
    extends java.lang.Object
    Storage sub-node for storing products of other nodes
    • Field Detail

      • storageOwner

        private final NodeBase storageOwner
      • products

        private final java.util.List<Product> products
    • Constructor Detail

      • Storage

        public Storage​(NodeBase owner)
    • Method Detail

      • storeProduct

        public void storeProduct​(Product product)
        Adds provided product into the storage.
        Parameters:
        product -
      • storeProducts

        public void storeProducts​(java.util.List<Product> products)
        Adds all of the provided products into the storage.
        Parameters:
        products -
      • getProduct

        public Product getProduct​(java.lang.String name,
                                  ProductType type)
        Finds a product (first if there is multiple of them) based on its name and type.
        Parameters:
        name - name of product to find
        type - type of product to find
        Returns:
        product if found, null if product is not in storage
      • getProducts

        public java.util.List<Product> getProducts()
      • getNumberOfStoredProducts

        public int getNumberOfStoredProducts()
        Returns number of products in storage.
        Returns:
      • containsProduct

        public boolean containsProduct​(Product product)
        Checks whether storage contains provided product.
        Parameters:
        product - product to check
        Returns:
        true if contains, false if not
      • containsProduct

        public boolean containsProduct​(java.lang.String name,
                                       ProductType type)
        Checks whether storage contains provided product.
        Parameters:
        name - name of product to check
        type - type of product to check
        Returns:
        true if contains, false if not
      • removeProduct

        public void removeProduct​(Product product)
        Removes provided product from storage if storage contains this product. (Removes only first found).
        Parameters:
        product - product to remove
      • doAction

        public void doAction​(ProductOperationType action,
                             java.lang.String productName)
                      throws java.lang.IllegalCallerException,
                             javax.naming.InsufficientResourcesException
        Proceed specific type of action on provided product if its possible.
        Parameters:
        action - type of product operation to do
        productName - product to process
        Throws:
        java.lang.IllegalCallerException
        javax.naming.InsufficientResourcesException
      • doAction

        public void doAction​(ProductOperationType action)
        Calls specific ProductOperation on each product in stock.
        Parameters:
        action - ProductOperationType
      • tick

        public void tick()