Class InventoryObserver
java.lang.Object
com.university.bookstore.observer.InventoryObserver
- All Implemented Interfaces:
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears all inventory data.Gets all inventory counts.Gets all total values.intgetInventoryCount(String materialId) Gets the inventory count for a specific material.Gets the name of this observer for identification purposes.intGets the total number of events processed.intGets the total number of materials in inventory.doubleGets the total value of all materials in inventory.doublegetTotalValue(String materialId) Gets the total value for a specific material.intGets the number of unique materials in inventory.voidonEvent(MaterialEvent event) Called when a material event occurs.toString()Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.university.bookstore.observer.MaterialObserver
onAdded, onRemoved
-
Constructor Details
-
InventoryObserver
public InventoryObserver()Creates a new inventory observer.
-
-
Method Details
-
onEvent
Description copied from interface:MaterialObserverCalled when a material event occurs.- Specified by:
onEventin interfaceMaterialObserver- Parameters:
event- the material event that occurred
-
getInventoryCount
Gets the inventory count for a specific material.- Parameters:
materialId- the material ID- Returns:
- the inventory count
-
getTotalValue
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
-
getAllTotalValues
-
clear
public void clear()Clears all inventory data. -
getObserverName
Description copied from interface:MaterialObserverGets the name of this observer for identification purposes.- Specified by:
getObserverNamein interfaceMaterialObserver- Returns:
- the observer name
-
toString
-