Produce { public void ifPresent(Consumer<T> consumer) { consumer.accept(result); } private  Produce(T result, Supplier<E> error);  Produce(T result);  Produce(Supplier<E> error); void ifPresent(Consumer<T> consumer); boolean hasResult(); boolean hasError(); @Nullable E getError(); T getResult();  }
@Test void ifPresent() { AtomicBoolean flag = new AtomicBoolean(false); WITH_RESULT.ifPresent(value -> { Assertions.assertEquals("result", value); flag.set(true); }); Assertions.assertTrue(flag.get()); }