Class IntervalTimer

All Implemented Interfaces:
IntervalTimerSupplier, StatisticSupplier

public final class IntervalTimer extends AbstractIntervalTimerSupplier
Basic mutable implementation of AccumulatedTimerSupplier.
  • Constructor Details

  • Method Details

    • getState

      public StatisticState getState()
      Description copied from interface: StatisticSupplier
      Returns the current state of the supplier.
      Returns:
      the state of the supplier
    • start

      public void start()
      Starts the timer; time will begin to accumulate
      Throws:
      IllegalStateException - if the timer is already started or has finished
    • stop

      public void stop()
      Stops the timer. This method can be called while in any state and thus is safe to call within a finally block.
    • snapshot

      public IntervalTimerSnapshot snapshot()
      Description copied from interface: IntervalTimerSupplier
      Creates a snapshot of this timer. If the timer is in the StatisticState.ACTIVE
      Returns:
      a snapshot of this statistic.
    • getStartTimeMillis

      public long getStartTimeMillis()
      Description copied from interface: IntervalTimerSupplier
      This will return the start time or an undefined value if never started.
      Returns:
      the start time or an undefined value if never started.
    • getEndTimeMillis

      public long getEndTimeMillis()
      Description copied from interface: IntervalTimerSupplier
      Returns the end time if finished, the current time if running, or an undefined value if never started. If this timer corresponds to a snapshot of a timer that is in the StatisticState.ACTIVE state, then this value will reflect the time at which the snapshot was taken.
      Returns:
      the end time if finished, the current time if running, or an undefined value if never started