Class AnalyticsObserver

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

public class AnalyticsObserver extends Object implements MaterialObserver
Observer that collects analytics data from material events. Tracks event counts, material statistics, and system performance metrics.
Since:
2024-09-15
Version:
3.0
Author:
Navid Mohaghegh
  • Constructor Details

    • AnalyticsObserver

      public AnalyticsObserver()
      Creates a new analytics 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
    • getEventStatistics

      public Map<String,Integer> getEventStatistics()
      Gets event statistics.
      Returns:
      map of event type to count
    • getEventCount

      public int getEventCount(String eventType)
      Gets the count for a specific event type.
      Parameters:
      eventType - the event type
      Returns:
      the event count
    • getTotalEvents

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

      public double getTotalInventoryValue()
      Gets the total inventory value.
      Returns:
      the total value
    • getMaterialTypeStatistics

      public Map<String,Integer> getMaterialTypeStatistics()
      Gets material type statistics.
      Returns:
      map of material type to count
    • getMaterialTypeCount

      public int getMaterialTypeCount(String materialType)
      Gets the count for a specific material type.
      Parameters:
      materialType - the material type
      Returns:
      the material count
    • getUniqueMaterialCount

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

      public long getFirstEventTime()
      Gets the time of the first event.
      Returns:
      the first event timestamp
    • getLastEventTime

      public long getLastEventTime()
      Gets the time of the last event.
      Returns:
      the last event timestamp
    • getEventTimeSpan

      public long getEventTimeSpan()
      Gets the time span of events.
      Returns:
      the time span in milliseconds
    • getAverageEventRate

      public double getAverageEventRate()
      Gets the average events per second.
      Returns:
      the average event rate
    • getAnalyticsData

      public AnalyticsObserver.AnalyticsData getAnalyticsData()
      Gets comprehensive analytics data.
      Returns:
      analytics data object
    • clear

      public void clear()
      Clears all analytics 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