@Test public void testExecuteIfAbsent() { final Integer[] data = { 0 }; OptionalLong.empty() .executeIfAbsent(new Runnable() { @Override public void run() { data[0] = 1; } }); assertThat(data[0], is(1)); }
@NotNull public OptionalLong executeIfAbsent(@NotNull Runnable action) { if (!isPresent()) { action.run(); } return this; }
OptionalLong { @NotNull public OptionalLong executeIfAbsent(@NotNull Runnable action) { if (!isPresent()) { action.run(); } return this; } }
OptionalLong { @NotNull public OptionalLong executeIfAbsent(@NotNull Runnable action) { if (!isPresent()) { action.run(); } return this; } private  OptionalLong(); private  OptionalLong(long value); }
OptionalLong { @NotNull public OptionalLong executeIfAbsent(@NotNull Runnable action) { if (!isPresent()) { action.run(); } return this; } private  OptionalLong(); private  OptionalLong(long value); @NotNull static OptionalLong empty(); @NotNull static OptionalLong of(long value); @NotNull static OptionalLong ofNullable(@Nullable Long value); long getAsLong(); boolean isPresent(); boolean isEmpty(); void ifPresent(@NotNull LongConsumer consumer); void ifPresentOrElse(@NotNull LongConsumer consumer, @NotNull Runnable emptyAction); @NotNull OptionalLong executeIfPresent(@NotNull LongConsumer consumer); @NotNull OptionalLong executeIfAbsent(@NotNull Runnable action); @Nullable R custom(@NotNull Function<OptionalLong, R> function); @NotNull OptionalLong filter(@NotNull LongPredicate predicate); @NotNull OptionalLong filterNot(@NotNull LongPredicate predicate); @NotNull OptionalLong map(@NotNull LongUnaryOperator mapper); @NotNull Optional<U> mapToObj(@NotNull LongFunction<U> mapper); @NotNull OptionalInt mapToInt(@NotNull LongToIntFunction mapper); @NotNull LongStream stream(); @NotNull OptionalLong or(@NotNull Supplier<OptionalLong> supplier); long orElse(long other); long orElseGet(@NotNull LongSupplier other); long orElseThrow(); long orElseThrow(@NotNull Supplier<X> exceptionSupplier); @Override boolean equals(Object obj); @Override int hashCode(); @NotNull @Override String toString(); }
OptionalLong { @NotNull public OptionalLong executeIfAbsent(@NotNull Runnable action) { if (!isPresent()) { action.run(); } return this; } private  OptionalLong(); private  OptionalLong(long value); @NotNull static OptionalLong empty(); @NotNull static OptionalLong of(long value); @NotNull static OptionalLong ofNullable(@Nullable Long value); long getAsLong(); boolean isPresent(); boolean isEmpty(); void ifPresent(@NotNull LongConsumer consumer); void ifPresentOrElse(@NotNull LongConsumer consumer, @NotNull Runnable emptyAction); @NotNull OptionalLong executeIfPresent(@NotNull LongConsumer consumer); @NotNull OptionalLong executeIfAbsent(@NotNull Runnable action); @Nullable R custom(@NotNull Function<OptionalLong, R> function); @NotNull OptionalLong filter(@NotNull LongPredicate predicate); @NotNull OptionalLong filterNot(@NotNull LongPredicate predicate); @NotNull OptionalLong map(@NotNull LongUnaryOperator mapper); @NotNull Optional<U> mapToObj(@NotNull LongFunction<U> mapper); @NotNull OptionalInt mapToInt(@NotNull LongToIntFunction mapper); @NotNull LongStream stream(); @NotNull OptionalLong or(@NotNull Supplier<OptionalLong> supplier); long orElse(long other); long orElseGet(@NotNull LongSupplier other); long orElseThrow(); long orElseThrow(@NotNull Supplier<X> exceptionSupplier); @Override boolean equals(Object obj); @Override int hashCode(); @NotNull @Override String toString();  }