Interface Timing.TimedWithError

All Known Implementing Classes:
Timing.TimedWithErrorNoResult, Timing.TimedWithErrorOrResult
Enclosing class:
Timing

public static sealed interface Timing.TimedWithError permits Timing.TimedWithErrorOrResult<R>, Timing.TimedWithErrorNoResult
Represents an operation that is timed and may throw a runtime exception.
API Note:
This uses RuntimeException rather than Exception because the timing methods accept a Runnable or a Supplier, which can only throw RuntimeException.
  • Method Details

    • getElapsedNanos

      long getElapsedNanos()
      Returns:
      the number of nanoseconds that elapsed during the operation
    • getElapsedMillis

      default long getElapsedMillis()
      Returns:
      the number of milliseconds that elapsed during the operation
    • operationSucceeded

      default boolean operationSucceeded()
      Returns:
      true if the operation completed without exception, otherwise false
    • hasException

      default boolean hasException()
      Returns:
      true if the operation threw an exception, otherwise false
    • getException

      Optional<RuntimeException> getException()
      Returns:
      an Optional that will contain a RuntimeException if the operation failed. If called when the operation succeeded, an empty Optional is always returned.