Class ThrowableCollector



  • @API(status=INTERNAL,
         since="5.0")
    public class ThrowableCollector
    extends java.lang.Object
    Simple component that can be used to collect one or more instances of Throwable.
    Since:
    5.0
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void assertEmpty​()
      Assert that this ThrowableCollector is empty (i.e., has not collected any Throwables).
      void execute​(Executable executable)
      Execute the supplied Executable and collect any Throwable thrown during the execution.
      java.lang.Throwable getThrowable​()
      Get the first Throwable collected by this ThrowableCollector.
      boolean isEmpty​()
      Determine if this ThrowableCollector is empty (i.e., has not collected any Throwables).
      boolean isNotEmpty​()
      Determine if this ThrowableCollector is not empty (i.e., has collected at least one Throwable).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ThrowableCollector

        public ThrowableCollector​()
    • Method Detail

      • execute

        public void execute​(Executable executable)
        Execute the supplied Executable and collect any Throwable thrown during the execution.
        Parameters:
        executable - the Executable to execute
        See Also:
        assertEmpty()
      • getThrowable

        public java.lang.Throwable getThrowable​()
        Get the first Throwable collected by this ThrowableCollector.

        If this collector is not empty, the first collected Throwable will be returned with any additional throwables suppressed in the first Throwable.

        Returns:
        the first collected Throwable or null if this ThrowableCollector is empty
        See Also:
        isEmpty(), assertEmpty()
      • isEmpty

        public boolean isEmpty​()
        Determine if this ThrowableCollector is empty (i.e., has not collected any Throwables).
      • isNotEmpty

        public boolean isNotEmpty​()
        Determine if this ThrowableCollector is not empty (i.e., has collected at least one Throwable).
      • assertEmpty

        public void assertEmpty​()
        Assert that this ThrowableCollector is empty (i.e., has not collected any Throwables).

        If this collector is not empty, the first collected Throwable will be thrown with any additional throwables suppressed in the first Throwable. Note, however, that the Throwable will not be wrapped. Rather, it will be masked as an unchecked exception.

        See Also:
        ExceptionUtils.throwAsUncheckedException(Throwable)