List of utility methods to do Stream Operation
boolean | startsWith(StreamassertTrue(StreamUtils.startsWith(Stream.of(1,2,3,4),Arrays.asList(1,2,3))); return startsWith(stream, iterable.iterator());
|
boolean | startsWith(Stream starts With return startsWith(stream, stream2.iterator());
|
Stream | stringPositions(StringBuilder toTest, Stream Tests the supplied StringBuilder for the presence of strings , and returns the positions of matching characters. if (toTest == null) { throw new IllegalArgumentException("StringBuilder must not be null."); if (strings == null) { throw new IllegalArgumentException("Invalid strings must not be null"); Stream.Builder<Integer> positionStream = Stream.builder(); strings.forEach(invalidString -> { ... |
List | toList(final Stream to List return stream.collect(Collectors.toList());
|
Stream | toParameter(Stream to Parameter return input.map(s -> new Object[] { s, exp }); |
String | toString(IntStream s) to String return s.mapToObj(String::valueOf).collect(Collectors.joining());
|
String | toString(LongStream ls) Consumes all the values provided by the passed LongStream, displaying them as an array of values (on a single line). StringBuilder sb = new StringBuilder("["); ls.peek(sb::append).peek(n -> sb.append(", ")).filter(n -> false).findAny(); String output = sb.substring(0, sb.length() - 2); return output + "]"; |
Stream | upcastStream(Stream extends T> stream) upcast Stream return (Stream<T>) stream;
|
Stream
| zip(List Convert a List of Stream into a Stream of List by associating each element of one list with the element at the same position in the latters. final List<Iterator<T>> iteratorsList = streams.stream().map(Stream::iterator).collect(Collectors.toList()); final Iterator<List<T>> zippedIterator = new Iterator<List<T>>() { @Override public boolean hasNext() { for (Iterator<T> it : iteratorsList) if (it.hasNext()) return true; return false; ... |
Stream | zipWithIndex(Stream extends T> stream, int startIndex) Zips the specified stream with its indices. return iterate(new Iterator<Map.Entry<Integer, T>>() { private final Iterator<? extends T> streamIterator = stream.iterator(); private int index = startIndex; @Override public boolean hasNext() { return streamIterator.hasNext(); @Override ... |