Class DataCollector<D>

java.lang.Object
com.storedobject.core.DataCollector<D>
Type Parameters:
D - The type of data being managed by the DataCollector.
All Implemented Interfaces:
Closeable, AutoCloseable

public class DataCollector<D> extends Object implements Closeable
A utility class responsible for periodically collecting and analyzing data, and notifying a DataDistributor of changes or activity.

The DataCollector runs a scheduled task that executes at a fixed interval. This task evaluates whether the data has changed using a provided Predicate. If a change is detected, the dataUpdated method of the DataDistributor is invoked. Otherwise, the pingReceived method of the DataDistributor is called to indicate that the periodic check occurred.

The frequency of data collection can be configured through the constructor. If the frequency is less than or equal to zero, a default interval of 5 seconds is used.

Author:
Syam