/** * If a value is present, returns a sequential {@link DoubleStream} * containing only that value, otherwise returns an empty * {@code DoubleStream}. * * <p><b>API Note:</b><br> * This method can be used to transform a {@code Stream} of optional doubles * to a {@code DoubleStream} of present doubles: * * <pre>{@code * Stream<OptionalDouble> os = .. * DoubleStream s = os.flatMapToDouble(OptionalDouble::stream) * }</pre> * * @return the optional value as a {@code DoubleStream} * @since 9 */ public DoubleStream stream() { if (isPresent) { return DoubleStreams.of(value); } else { return DoubleStreams.empty(); } }
/** * If a value is present, returns a sequential {@link DoubleStream} * containing only that value, otherwise returns an empty * {@code DoubleStream}. * * <p><b>API Note:</b><br> * This method can be used to transform a {@code Stream} of optional doubles * to a {@code DoubleStream} of present doubles: * * <pre>{@code * Stream<OptionalDouble> os = .. * DoubleStream s = os.flatMapToDouble(OptionalDouble::stream) * }</pre> * * @return the optional value as a {@code DoubleStream} * @since 9 */ public DoubleStream stream() { if (isPresent) { return DoubleStreams.of(value); } else { return DoubleStreams.empty(); } }