Class EventBasedCounter
- java.lang.Object
-
- org.djutils.event.EventProducer
-
- org.djutils.stats.summarizers.event.EventBasedCounter
-
- All Implemented Interfaces:
Serializable,EventListener,EventListenerInterface,EventProducerInterface,CounterInterface
public class EventBasedCounter extends EventProducer implements EventListenerInterface, CounterInterface
The Counter class defines a statistics event counter. It extends an EventProducer so it can keep listeners informed about new observations, and it listens to external events to be able to receive observations, in addition to the ingest(...) method.Copyright (c) 2002-2021 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://simulation.tudelft.nl. The DSOL project is distributed under a three-clause BSD-style license, which can be found at https://simulation.tudelft.nl/dsol/3.0/license.html.
- Author:
- Alexander Verbraeck, Peter Jacobs
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.djutils.event.EventProducer
eventProducerImpl
-
Fields inherited from interface org.djutils.event.EventProducerInterface
FIRST_POSITION, LAST_POSITION
-
-
Constructor Summary
Constructors Constructor Description EventBasedCounter(String description)Construct a new EventBasedCounter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidfireEvents()Method that can be overridden to fire own events or additional events when ingesting an observation.longgetCount()Returns the current counter value.StringgetDescription()Returns the description of the counter.longgetN()Returns the current number of observations.SerializablegetSourceId()longingest(long value)Process one observed value.voidinitialize()Initializes the counter.voidnotify(EventInterface event)StringtoString()-
Methods inherited from class org.djutils.event.EventProducer
addListener, addListener, addListener, addListener, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, getEventTypesWithListeners, getListenerReferences, hasListeners, numberOfListeners, removeAllListeners, removeAllListeners, removeListener
-
-
-
-
Constructor Detail
-
EventBasedCounter
public EventBasedCounter(String description)
Construct a new EventBasedCounter.- Parameters:
description- String; the description for this counter
-
-
Method Detail
-
getSourceId
public Serializable getSourceId()
- Specified by:
getSourceIdin interfaceEventProducerInterface- Specified by:
getSourceIdin classEventProducer
-
getCount
public long getCount()
Returns the current counter value.- Specified by:
getCountin interfaceCounterInterface- Returns:
- long; the counter value
-
getN
public long getN()
Returns the current number of observations.- Specified by:
getNin interfaceCounterInterface- Returns:
- long; the number of observations
-
notify
public void notify(EventInterface event)
- Specified by:
notifyin interfaceEventListenerInterface
-
ingest
public long ingest(long value)
Process one observed value.- Specified by:
ingestin interfaceCounterInterface- Parameters:
value- long; the value to process- Returns:
- long; the value
-
fireEvents
protected void fireEvents()
Method that can be overridden to fire own events or additional events when ingesting an observation.
-
initialize
public void initialize()
Initializes the counter.- Specified by:
initializein interfaceCounterInterface
-
getDescription
public String getDescription()
Returns the description of the counter.- Specified by:
getDescriptionin interfaceCounterInterface- Returns:
- String; the description
-
-