ResultSet implements Iterable<O>, Closeable { public Stream<O> stream() { return StreamSupport.stream(this.spliterator(), false) .onClose(this::close); }  abstract Iterator<O> iterator(); abstract boolean contains(O object); abstract boolean matches(O object); abstract Query<O> getQuery(); abstract QueryOptions getQueryOptions(); O uniqueResult(); abstract int getRetrievalCost(); abstract int getMergeCost(); abstract int size(); boolean isEmpty(); boolean isNotEmpty(); abstract void close(); Spliterator<O> spliterator(); Stream<O> stream();  }
@Test public void testStream() { List<String> input = asList("a", "b", "c", "d"); IndexedCollection<String> indexedCollection = new ConcurrentIndexedCollection<String>(); indexedCollection.addAll(input); ResultSet<String> resultSet = indexedCollection.retrieve(all(String.class), queryOptions(orderBy(ascending(selfAttribute(String.class))))); Stream<String> stream = resultSet.stream(); List<String> output = stream.collect(toList()); assertEquals(input, output); }