@Test public void testOrElseGet() { assertEquals(21, OptionalInt.empty().orElseGet(new IntSupplier() { @Override public int getAsInt() { return 21; } })); assertEquals(21, OptionalInt.of(21).orElseGet(new IntSupplier() { @Override public int getAsInt() { throw new IllegalStateException(); } })); }
public int orElseGet(@NotNull IntSupplier other) { return isPresent ? value : other.getAsInt(); }
OptionalInt { public int orElseGet(@NotNull IntSupplier other) { return isPresent ? value : other.getAsInt(); } }
OptionalInt { public int orElseGet(@NotNull IntSupplier other) { return isPresent ? value : other.getAsInt(); } private  OptionalInt(); private  OptionalInt(int value); }
OptionalInt { public int orElseGet(@NotNull IntSupplier other) { return isPresent ? value : other.getAsInt(); } private  OptionalInt(); private  OptionalInt(int value); @NotNull static OptionalInt empty(); @NotNull static OptionalInt of(int value); @NotNull static OptionalInt ofNullable(@Nullable Integer value); int getAsInt(); boolean isPresent(); boolean isEmpty(); void ifPresent(@NotNull IntConsumer consumer); void ifPresentOrElse(@NotNull IntConsumer consumer, @NotNull Runnable emptyAction); @NotNull OptionalInt executeIfPresent(@NotNull IntConsumer consumer); @NotNull OptionalInt executeIfAbsent(@NotNull Runnable action); @Nullable R custom(@NotNull Function<OptionalInt, R> function); @NotNull OptionalInt filter(@NotNull IntPredicate predicate); @NotNull OptionalInt filterNot(@NotNull IntPredicate predicate); @NotNull OptionalInt map(@NotNull IntUnaryOperator mapper); @NotNull Optional<U> mapToObj(@NotNull IntFunction<U> mapper); @NotNull OptionalLong mapToLong(@NotNull IntToLongFunction mapper); @NotNull OptionalDouble mapToDouble(@NotNull IntToDoubleFunction mapper); @NotNull IntStream stream(); @NotNull OptionalInt or(@NotNull Supplier<OptionalInt> supplier); int orElse(int other); int orElseGet(@NotNull IntSupplier other); int orElseThrow(); int orElseThrow(@NotNull Supplier<X> exceptionSupplier); @Override boolean equals(Object obj); @Override int hashCode(); @NotNull @Override String toString(); }
OptionalInt { public int orElseGet(@NotNull IntSupplier other) { return isPresent ? value : other.getAsInt(); } private  OptionalInt(); private  OptionalInt(int value); @NotNull static OptionalInt empty(); @NotNull static OptionalInt of(int value); @NotNull static OptionalInt ofNullable(@Nullable Integer value); int getAsInt(); boolean isPresent(); boolean isEmpty(); void ifPresent(@NotNull IntConsumer consumer); void ifPresentOrElse(@NotNull IntConsumer consumer, @NotNull Runnable emptyAction); @NotNull OptionalInt executeIfPresent(@NotNull IntConsumer consumer); @NotNull OptionalInt executeIfAbsent(@NotNull Runnable action); @Nullable R custom(@NotNull Function<OptionalInt, R> function); @NotNull OptionalInt filter(@NotNull IntPredicate predicate); @NotNull OptionalInt filterNot(@NotNull IntPredicate predicate); @NotNull OptionalInt map(@NotNull IntUnaryOperator mapper); @NotNull Optional<U> mapToObj(@NotNull IntFunction<U> mapper); @NotNull OptionalLong mapToLong(@NotNull IntToLongFunction mapper); @NotNull OptionalDouble mapToDouble(@NotNull IntToDoubleFunction mapper); @NotNull IntStream stream(); @NotNull OptionalInt or(@NotNull Supplier<OptionalInt> supplier); int orElse(int other); int orElseGet(@NotNull IntSupplier other); int orElseThrow(); int orElseThrow(@NotNull Supplier<X> exceptionSupplier); @Override boolean equals(Object obj); @Override int hashCode(); @NotNull @Override String toString();  }