Class InventoryObserver

java.lang.Object
com.university.bookstore.observer.InventoryObserver
All Implemented Interfaces:
MaterialObserver

public class InventoryObserver extends Object implements MaterialObserver
Observer that tracks inventory changes for materials. Maintains counts and statistics for materials in the system.
Since:
2024-09-15
Version:
3.0
Author:
Navid Mohaghegh
  • Constructor Details

    • InventoryObserver

      public InventoryObserver()
      Creates a new inventory observer.
  • Method Details

    • onEvent

      public void onEvent(MaterialEvent event)
      Description copied from interface: MaterialObserver
      Called when a material event occurs.
      Specified by:
      onEvent in interface MaterialObserver
      Parameters:
      event - the material event that occurred
    • getInventoryCount

      public int getInventoryCount(String materialId)
      Gets the inventory count for a specific material.
      Parameters:
      materialId - the material ID
      Returns:
      the inventory count
    • getTotalValue

      public double getTotalValue(String materialId)
      Gets the total value for a specific material.
      Parameters:
      materialId - the material ID
      Returns:
      the total value
    • getTotalInventoryCount

      public int getTotalInventoryCount()
      Gets the total number of materials in inventory.
      Returns:
      the total count
    • getTotalInventoryValue

      public double getTotalInventoryValue()
      Gets the total value of all materials in inventory.
      Returns:
      the total value
    • getUniqueMaterialCount

      public int getUniqueMaterialCount()
      Gets the number of unique materials in inventory.
      Returns:
      the unique material count
    • getTotalEvents

      public int getTotalEvents()
      Gets the total number of events processed.
      Returns:
      the event count
    • getAllInventoryCounts

      public Map<String,Integer> getAllInventoryCounts()
      Gets all inventory counts.
      Returns:
      map of material ID to count
    • getAllTotalValues

      public Map<String,Double> getAllTotalValues()
      Gets all total values.
      Returns:
      map of material ID to total value
    • clear

      public void clear()
      Clears all inventory data.
    • getObserverName

      public String getObserverName()
      Description copied from interface: MaterialObserver
      Gets the name of this observer for identification purposes.
      Specified by:
      getObserverName in interface MaterialObserver
      Returns:
      the observer name
    • toString

      public String toString()
      Overrides:
      toString in class Object