Class WindowTimeRTIndicator

All Implemented Interfaces:
ClockAware, Resettable, RTIndicator

public class WindowTimeRTIndicator extends OnChangeRTIndicator implements ClockAware
Time-based windowed indicator that batches updates over a configurable duration. Updates are accumulated via the decorated indicator, but change notifications are only fired when the elapsed time since the last window boundary exceeds the configured window duration. Supports an optional delay mode where the decorated indicator is only updated at window boundaries.
  • Constructor Details

  • Method Details

    • getWindowTimeDuration

      public Duration getWindowTimeDuration()
    • tick

      public void tick()
      Advance internal clock the windowTime Useful for tests
    • getPrevInstant

      public Instant getPrevInstant()
      The boundaries of the window being reported, read straight off this indicator during the notification — no state store involved.
      Returns:
      when the window that last closed had opened, or null before the first boundary
    • getCurrInstant

      public Instant getCurrInstant()
      Returns:
      when that window closed, which is also where the currently open one starts; null before the first update
    • addOnChangeListener

      public void addOnChangeListener(OnChangeRTIndicator.OnChangeListener listener)
      Binds this window to a listener that asks for it, so the listener can read the boundaries above.
      Overrides:
      addOnChangeListener in class OnChangeRTIndicator
      Parameters:
      listener - the listener to register
    • setClockSupplier

      public void setClockSupplier(Supplier<Clock> clockSupplier)
      Specified by:
      setClockSupplier in interface ClockAware
      Overrides:
      setClockSupplier in class AbstractDecorableIncrementalRTIndicator
    • setDelayUpdates

      public void setDelayUpdates(boolean delayUpdates)
    • isEnableEvents

      public boolean isEnableEvents()
      Overrides:
      isEnableEvents in class OnChangeRTIndicator
    • setEnableEvents

      public void setEnableEvents(boolean enableEvents)
      Overrides:
      setEnableEvents in class OnChangeRTIndicator
    • update

      public double update(double newValue)
      Processes a new value with time-window gating. On the first call, captures the initial timestamp and delegates to the parent. On subsequent calls, checks if the window duration has elapsed since the last boundary. If so, it advances the boundary — recording the closed window's instants on this indicator, where listeners read them — and fires the notification. If the window has not elapsed, the indicator retains its previous value (suppresses intermediate changes). In delay mode, the decorated indicator is only updated at window boundaries.
      Specified by:
      update in interface RTIndicator
      Overrides:
      update in class AbstractDecorableIncrementalRTIndicator
      Parameters:
      newValue - the new input value
      Returns:
      the indicator value (updated only at window boundaries)