Java Code Examples for java.util.stream.LongStream#empty()
The following examples show how to use
java.util.stream.LongStream#empty() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Streams.java From arctic-sea with Apache License 2.0 | 5 votes |
/** * Factory function for creating a {@code Stream} from an array. * * @param array the array * @return the stream */ public static LongStream stream(long[] array) { if (array == null) { return LongStream.empty(); } return Arrays.stream(array); }
Example 2
Source File: PluginDefaultGroovyMethods.java From groovy with Apache License 2.0 | 5 votes |
/** * If a value is present in the {@link OptionalLong}, returns a {@link LongStream} * with the value as its source or else an empty stream. * * @since 3.0.0 */ public static LongStream stream(final OptionalLong self) { if (!self.isPresent()) { return LongStream.empty(); } return LongStream.of(self.getAsLong()); }
Example 3
Source File: Unit5MyExtra.java From hol-streams with Apache License 2.0 | 4 votes |
@Override public LongStream factorials() { return LongStream.empty(); }
Example 4
Source File: OptionalLong.java From Bytecoder with Apache License 2.0 | 3 votes |
/** * If a value is present, returns a sequential {@link LongStream} containing * only that value, otherwise returns an empty {@code LongStream}. * * @apiNote * This method can be used to transform a {@code Stream} of optional longs * to an {@code LongStream} of present longs: * <pre>{@code * Stream<OptionalLong> os = .. * LongStream s = os.flatMapToLong(OptionalLong::stream) * }</pre> * * @return the optional value as an {@code LongStream} * @since 9 */ public LongStream stream() { if (isPresent) { return LongStream.of(value); } else { return LongStream.empty(); } }
Example 5
Source File: OptionalLong.java From openjdk-jdk9 with GNU General Public License v2.0 | 3 votes |
/** * If a value is present, returns a sequential {@link LongStream} containing * only that value, otherwise returns an empty {@code LongStream}. * * @apiNote * This method can be used to transform a {@code Stream} of optional longs * to an {@code LongStream} of present longs: * <pre>{@code * Stream<OptionalLong> os = .. * LongStream s = os.flatMapToLong(OptionalLong::stream) * }</pre> * * @return the optional value as an {@code LongStream} * @since 9 */ public LongStream stream() { if (isPresent) { return LongStream.of(value); } else { return LongStream.empty(); } }
Example 6
Source File: LongStreamExample.java From levelup-java-examples with Apache License 2.0 | 3 votes |
@Test public void longstream_empty() { LongStream emptyStream = LongStream.empty(); assertEquals(0, emptyStream.count()); }