Last change
on this file since 10597 was 10585, checked in by Don-vip, 8 years ago |
see #11390, fix #12905 - Add more information to the bug report (patch by michael2402) - gsoc-core - requires java 8
|
File size:
865 bytes
|
Line | |
---|
1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.tools;
|
---|
3 |
|
---|
4 | import java.util.Iterator;
|
---|
5 | import java.util.Spliterator;
|
---|
6 | import java.util.Spliterators;
|
---|
7 | import java.util.stream.Stream;
|
---|
8 | import java.util.stream.StreamSupport;
|
---|
9 |
|
---|
10 | /**
|
---|
11 | * Utility methods for streams.
|
---|
12 | * @author Michael Zangl
|
---|
13 | * @since 10585
|
---|
14 | */
|
---|
15 | public final class StreamUtils {
|
---|
16 |
|
---|
17 | /**
|
---|
18 | * Utility class
|
---|
19 | */
|
---|
20 | private StreamUtils() {}
|
---|
21 |
|
---|
22 | /**
|
---|
23 | * Convert an iterator to a stream.
|
---|
24 | * @param <T> The element type to iterate over
|
---|
25 | * @param iterator The iterator
|
---|
26 | * @return The stream of for that iterator.
|
---|
27 | */
|
---|
28 | public static <T> Stream<T> toStream(Iterator<? extends T> iterator) {
|
---|
29 | Spliterator<T> spliterator = Spliterators.spliteratorUnknownSize(iterator, Spliterator.ORDERED);
|
---|
30 | return StreamSupport.stream(spliterator, false);
|
---|
31 | }
|
---|
32 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.