Class AnalyticsObserver
java.lang.Object
com.university.bookstore.observer.AnalyticsObserver
- All Implemented Interfaces:
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classComprehensive analytics data container. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears all analytics data.Gets comprehensive analytics data.doubleGets the average events per second.intgetEventCount(String eventType) Gets the count for a specific event type.Gets event statistics.longGets the time span of events.longGets the time of the first event.longGets the time of the last event.intgetMaterialTypeCount(String materialType) Gets the count for a specific material type.Gets material type statistics.Gets the name of this observer for identification purposes.intGets the total number of events processed.doubleGets the total inventory value.intGets the number of unique materials.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
-
AnalyticsObserver
public AnalyticsObserver()Creates a new analytics 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
-
getEventStatistics
-
getEventCount
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
-
getMaterialTypeCount
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
Gets comprehensive analytics data.- Returns:
- analytics data object
-
clear
public void clear()Clears all analytics data. -
getObserverName
Description copied from interface:MaterialObserverGets the name of this observer for identification purposes.- Specified by:
getObserverNamein interfaceMaterialObserver- Returns:
- the observer name
-
toString
-