@Test void onError() { AtomicInteger integer = new AtomicInteger(-1); Result.error(integer.get()).onError(err -> integer.set(Math.abs(err))); assertEquals(1, integer.get()); }
public Result<V, E> onError(Consumer<E> consumer) { if (isErr()) { consumer.accept(error); } return this; }
Result { public Result<V, E> onError(Consumer<E> consumer) { if (isErr()) { consumer.accept(error); } return this; } }
Result { public Result<V, E> onError(Consumer<E> consumer) { if (isErr()) { consumer.accept(error); } return this; } private  Result(@Nullable V value, @Nullable E error); }
Result { public Result<V, E> onError(Consumer<E> consumer) { if (isErr()) { consumer.accept(error); } return this; } private  Result(@Nullable V value, @Nullable E error); boolean isOk(); boolean isErr(); V get(); E getError(); Result<R, E> map(Function<V, R> function); Result<R, E> flatMap(Function<V, Result<R, E>> function); Result<V, E> orElse(Function<E, Result<V, E>> orElse); V orElseGet(Function<E, V> orElse); V orElseThrow(ThrowingFunction<E, T, T> consumer); Result<V, E> peek(Consumer<V> consumer); Result<V, E> onError(Consumer<E> consumer); static Result<V, E> ok(V value); static Result<V, E> error(E err); }
Result { public Result<V, E> onError(Consumer<E> consumer) { if (isErr()) { consumer.accept(error); } return this; } private  Result(@Nullable V value, @Nullable E error); boolean isOk(); boolean isErr(); V get(); E getError(); Result<R, E> map(Function<V, R> function); Result<R, E> flatMap(Function<V, Result<R, E>> function); Result<V, E> orElse(Function<E, Result<V, E>> orElse); V orElseGet(Function<E, V> orElse); V orElseThrow(ThrowingFunction<E, T, T> consumer); Result<V, E> peek(Consumer<V> consumer); Result<V, E> onError(Consumer<E> consumer); static Result<V, E> ok(V value); static Result<V, E> error(E err);  }