/** * Always run the given action, works like a finally clause. Exception and value might be null. * Exception will be null in case of success. * * @param action Finally action. * @return This try result. */ public Value<V> onComplete(final Throwing.Consumer2<V, Throwable> action) { try { V value = isSuccess() ? get() : null; action.accept(value, getCause().orElse(null)); return this; } catch (Throwable x) { return (Value<V>) failure(x); } }
public Try run(Throwing.Consumer2<R1, R2> fn) { return Try.run(() -> { try (R1 r1 = this.r1.get(); R2 r2 = this.r2.get()) { fn.accept(r1, r2); } }); } }