@Test void test() { assertEquals(asList(asList("Foo", "Bar", "ON"), asList("OFF", "was")), partition( Stream.of("Foo", "Bar", "ON", "Fire", "OFF", "was", "destroyed"), s -> s.length() > 3) .collect(Collectors.toList())); assertEquals(asList(asList("Foo", "Bar", "OFF", "Fire", "OFF", "was")), partition( Stream.of("Foo", "Bar", "OFF", "Fire", "OFF", "was", "destroyed"), s -> s.length() > 4) .collect(Collectors.toList())); assertEquals(asList(asList(), asList(), asList("ON"), asList("ON"), asList()), partition( Stream.of("Foo", "Bar", "ON", "Fire", "ON", "was", "destroyed"), s -> s.length() > 2) .collect(Collectors.toList())); }
public static <T> Stream<List<T>> partition(final Stream<T> stream, final Predicate<T> partitionSeparator) { return new KeywordPartitioner<>(stream, partitionSeparator).asStream(); }
KeywordPartitioner implements Iterator<List<E>> { public static <T> Stream<List<T>> partition(final Stream<T> stream, final Predicate<T> partitionSeparator) { return new KeywordPartitioner<>(stream, partitionSeparator).asStream(); } }
KeywordPartitioner implements Iterator<List<E>> { public static <T> Stream<List<T>> partition(final Stream<T> stream, final Predicate<T> partitionSeparator) { return new KeywordPartitioner<>(stream, partitionSeparator).asStream(); } KeywordPartitioner(final Stream<E> stream, final Predicate<E> partitionSeparator);  KeywordPartitioner(final Iterator<E> iterator, final Predicate<E> partitionSeparator); }
KeywordPartitioner implements Iterator<List<E>> { public static <T> Stream<List<T>> partition(final Stream<T> stream, final Predicate<T> partitionSeparator) { return new KeywordPartitioner<>(stream, partitionSeparator).asStream(); } KeywordPartitioner(final Stream<E> stream, final Predicate<E> partitionSeparator);  KeywordPartitioner(final Iterator<E> iterator, final Predicate<E> partitionSeparator); static Stream<List<T>> partition(final Stream<T> stream, final Predicate<T> partitionSeparator); @Override boolean hasNext(); @Override List<E> next(); Stream<List<E>> asStream(); }
KeywordPartitioner implements Iterator<List<E>> { public static <T> Stream<List<T>> partition(final Stream<T> stream, final Predicate<T> partitionSeparator) { return new KeywordPartitioner<>(stream, partitionSeparator).asStream(); } KeywordPartitioner(final Stream<E> stream, final Predicate<E> partitionSeparator);  KeywordPartitioner(final Iterator<E> iterator, final Predicate<E> partitionSeparator); static Stream<List<T>> partition(final Stream<T> stream, final Predicate<T> partitionSeparator); @Override boolean hasNext(); @Override List<E> next(); Stream<List<E>> asStream();  }