@Test public void testMapToLong() { assertThat(OptionalDouble.of(0.2).mapToLong(new DoubleToLongFunction() { @Override public long applyAsLong(double value) { return (long) (value * 10); } }).getAsLong(), is(2L)); assertFalse(OptionalDouble.empty().mapToLong(new DoubleToLongFunction() { @Override public long applyAsLong(double value) { fail(); return 0; } }).isPresent()); }
@NotNull public OptionalLong mapToLong(@NotNull DoubleToLongFunction mapper) { if (!isPresent()) { return OptionalLong.empty(); } Objects.requireNonNull(mapper); return OptionalLong.of(mapper.applyAsLong(value)); }
OptionalDouble { @NotNull public OptionalLong mapToLong(@NotNull DoubleToLongFunction mapper) { if (!isPresent()) { return OptionalLong.empty(); } Objects.requireNonNull(mapper); return OptionalLong.of(mapper.applyAsLong(value)); } }
OptionalDouble { @NotNull public OptionalLong mapToLong(@NotNull DoubleToLongFunction mapper) { if (!isPresent()) { return OptionalLong.empty(); } Objects.requireNonNull(mapper); return OptionalLong.of(mapper.applyAsLong(value)); } private  OptionalDouble(); private  OptionalDouble(double value); }
OptionalDouble { @NotNull public OptionalLong mapToLong(@NotNull DoubleToLongFunction mapper) { if (!isPresent()) { return OptionalLong.empty(); } Objects.requireNonNull(mapper); return OptionalLong.of(mapper.applyAsLong(value)); } 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 OptionalLong mapToLong(@NotNull DoubleToLongFunction mapper) { if (!isPresent()) { return OptionalLong.empty(); } Objects.requireNonNull(mapper); return OptionalLong.of(mapper.applyAsLong(value)); } 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();  }