Class Inventory

java.lang.Object
csce331.group13.project2.backend.Inventory

public class Inventory extends Object
Singleton class that manages the in-memory inventory cache. Provides methods to add, update, and reduce inventory items.
Author:
Varish Kongara, Austin Glander
  • Field Details

  • Constructor Details

    • Inventory

      public Inventory()
      Private constructor that initializes the inventory by loading all items from the database.
  • Method Details

    • getInstance

      public static Inventory getInstance()
      Returns the singleton instance of the Inventory class.
      Returns:
      The single Inventory instance.
    • addInventoryItem

      public boolean addInventoryItem(InventoryItem inventoryItem)
      Adds a new inventory item to both the database and the in-memory cache.
      Parameters:
      inventoryItem - The InventoryItem to add.
      Returns:
      true if the item was successfully added; false otherwise.
    • updateInventoryItem

      public boolean updateInventoryItem(InventoryItem inventoryItem)
      Updates an existing inventory item in the database.
      Parameters:
      inventoryItem - The InventoryItem with updated values.
      Returns:
      true if the update was successful; false otherwise.
    • reduceInventory

      public void reduceInventory(UUID menuItemId, int quantity) throws SQLException
      Reduces the stock of inventory items associated with a menu item.
      Parameters:
      menuItemId - menu item to reduce stock for
      quantity - quantity to remove
      Throws:
      SQLException