@Test public void testExecuteIfAbsent() { final Integer[] data = { 0 }; OptionalDouble.empty() .executeIfAbsent(new Runnable() { @Override public void run() { data[0] = 1; } }); assertThat(data[0], is(1)); }
@NotNull public OptionalDouble executeIfAbsent(@NotNull Runnable action) { if (!isPresent()) { action.run(); } return this; }
OptionalDouble { @NotNull public OptionalDouble executeIfAbsent(@NotNull Runnable action) { if (!isPresent()) { action.run(); } return this; } }
OptionalDouble { @NotNull public OptionalDouble executeIfAbsent(@NotNull Runnable action) { if (!isPresent()) { action.run(); } return this; } private  OptionalDouble(); private  OptionalDouble(double value); }
OptionalDouble { @NotNull public OptionalDouble executeIfAbsent(@NotNull Runnable action) { if (!isPresent()) { action.run(); } return this; } private  OptionalDouble(); private  OptionalDouble(double value); @NotNull static OptionalDouble empty(); @NotNull static OptionalDouble of(double value); @NotNull static OptionalDouble ofNullable(@Nullable Double value); double getAsDouble(); boolean isPresent(); boolean isEmpty(); void ifPresent(@NotNull DoubleConsumer consumer); void ifPresentOrElse(@NotNull DoubleConsumer consumer, @NotNull Runnable emptyAction); @NotNull OptionalDouble executeIfPresent(@NotNull DoubleConsumer consumer); @NotNull OptionalDouble executeIfAbsent(@NotNull Runnable action); @Nullable R custom(@NotNull Function<OptionalDouble, R> function); @NotNull OptionalDouble filter(@NotNull DoublePredicate predicate); @NotNull OptionalDouble filterNot(@NotNull DoublePredicate predicate); @NotNull OptionalDouble map(@NotNull DoubleUnaryOperator mapper); @NotNull Optional<U> mapToObj(@NotNull DoubleFunction<U> mapper); @NotNull OptionalInt mapToInt(@NotNull DoubleToIntFunction mapper); @NotNull OptionalLong mapToLong(@NotNull DoubleToLongFunction mapper); @NotNull DoubleStream stream(); @NotNull OptionalDouble or(@NotNull Supplier<OptionalDouble> supplier); double orElse(double other); double orElseGet(@NotNull DoubleSupplier other); double orElseThrow(); double orElseThrow(@NotNull Supplier<X> exceptionSupplier); @Override boolean equals(Object obj); @Override int hashCode(); @NotNull @Override String toString(); }
OptionalDouble { @NotNull public OptionalDouble executeIfAbsent(@NotNull Runnable action) { if (!isPresent()) { action.run(); } return this; } private  OptionalDouble(); private  OptionalDouble(double value); @NotNull static OptionalDouble empty(); @NotNull static OptionalDouble of(double value); @NotNull static OptionalDouble ofNullable(@Nullable Double value); double getAsDouble(); boolean isPresent(); boolean isEmpty(); void ifPresent(@NotNull DoubleConsumer consumer); void ifPresentOrElse(@NotNull DoubleConsumer consumer, @NotNull Runnable emptyAction); @NotNull OptionalDouble executeIfPresent(@NotNull DoubleConsumer consumer); @NotNull OptionalDouble executeIfAbsent(@NotNull Runnable action); @Nullable R custom(@NotNull Function<OptionalDouble, R> function); @NotNull OptionalDouble filter(@NotNull DoublePredicate predicate); @NotNull OptionalDouble filterNot(@NotNull DoublePredicate predicate); @NotNull OptionalDouble map(@NotNull DoubleUnaryOperator mapper); @NotNull Optional<U> mapToObj(@NotNull DoubleFunction<U> mapper); @NotNull OptionalInt mapToInt(@NotNull DoubleToIntFunction mapper); @NotNull OptionalLong mapToLong(@NotNull DoubleToLongFunction mapper); @NotNull DoubleStream stream(); @NotNull OptionalDouble or(@NotNull Supplier<OptionalDouble> supplier); double orElse(double other); double orElseGet(@NotNull DoubleSupplier other); double orElseThrow(); double orElseThrow(@NotNull Supplier<X> exceptionSupplier); @Override boolean equals(Object obj); @Override int hashCode(); @NotNull @Override String toString();  }