Class TimestampedObserver


  • public class TimestampedObserver
    extends ObservableInputStream.Observer
    An observer with timestamps.

    For example:

     final TimestampedObserver timetampedObserver = new TimestampedObserver();
     try (ObservableInputStream inputStream = new ObservableInputStream(...),
         timetampedObserver)) {
         ...
     }
     System.out.printf("IO duration: %s%n", timetampedObserver.getOpenToCloseDuration());
     
    Since:
    2.9.0
    • Constructor Detail

      • TimestampedObserver

        public TimestampedObserver()
    • Method Detail

      • getCloseInstant

        public java.time.Instant getCloseInstant()
        Gets the instant for when this instance was closed.
        Returns:
        the instant for when closed was called.
      • getOpenInstant

        public java.time.Instant getOpenInstant()
        Gets the instant for when this instance was created.
        Returns:
        the instant for when this instance was created.
      • getOpenToCloseDuration

        public java.time.Duration getOpenToCloseDuration()
        Gets the Duration between creation and close.
        Returns:
        the Duration between creation and close.
      • getOpenToNowDuration

        public java.time.Duration getOpenToNowDuration()
        Gets the Duration between creation and now.
        Returns:
        the Duration between creation and now.
      • isClosed

        public boolean isClosed()
        Tests whether closed() has been called.
        Returns:
        whether closed() has been called.
        Since:
        2.12.0
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object