Class FinallyRunAll

  • All Implemented Interfaces:
    Runnable

    public class FinallyRunAll
    extends Object
    implements Runnable
    Force all actions in a list to run. Usage:
     
     FinallyAll.run(
       () -> action1(),
       () -> action2(),
       () -> actionN()
     );
     
     
    This is more succinct than nested finally blocks such as:
     {@code
     try { action1(); } catch (Exception e) { throw new RuntimeException(e); } finally {
       try { action2(); } catch ... {
         try { actionN(); } catch ... {
         }
       }
     }