com.univocity.api.common
Class TimedNotificationHandler<T>

java.lang.Object
  extended by com.univocity.api.common.TimedNotificationHandler<T>
All Implemented Interfaces:
NotificationHandler<T>

public abstract class TimedNotificationHandler<T>
extends Object
implements NotificationHandler<T>

A basic NotificationHandler implementation that filters out excessive notifications and only processes them after a given interval has been elapsed since the last notification was processed, or if the last notification is received.

Author:
uniVocity Software Pty Ltd - dev@univocity.com

Constructor Summary
TimedNotificationHandler(long notificationInterval)
          Creates a timed notification handler, which will ensure the onNotification(Object, boolean) method is called at a given frequency.
 
Method Summary
 void notify(T notification, boolean lastNotification)
          Notifies of some action or update.
protected abstract  void onNotification(T notification, boolean lastNotification)
          Invoked when a notification has been received after the notification interval has been elapsed, or if the notification is the last one to be received.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TimedNotificationHandler

public TimedNotificationHandler(long notificationInterval)
Creates a timed notification handler, which will ensure the onNotification(Object, boolean) method is called at a given frequency.

Parameters:
notificationInterval - the interval, in milliseconds, between each call to onNotification(Object, boolean)
Method Detail

notify

public final void notify(T notification,
                         boolean lastNotification)
Description copied from interface: NotificationHandler
Notifies of some action or update.

Specified by:
notify in interface NotificationHandler<T>
Parameters:
notification - the notification object with information about what happened.
lastNotification - flag indicating whether this is the last notification to be received.

onNotification

protected abstract void onNotification(T notification,
                                       boolean lastNotification)
Invoked when a notification has been received after the notification interval has been elapsed, or if the notification is the last one to be received.

Parameters:
notification - the notification object with details about the process being observed.
lastNotification - a flag indicating whether this is the last notification to be received.


Copyright © 2018 uniVocity Software Pty Ltd. All rights reserved.