diff --git a/bundles/org.eclipse.equinox.p2.metadata/.settings/.api_filters b/bundles/org.eclipse.equinox.p2.metadata/.settings/.api_filters
index d8f48e5c23..6b7f3a23f8 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/.settings/.api_filters
+++ b/bundles/org.eclipse.equinox.p2.metadata/.settings/.api_filters
@@ -8,4 +8,12 @@
+
+
+
+
+
+
+
+
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/CollectionResult.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/CollectionResult.java
index 483efac5d1..73ca211d4c 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/CollectionResult.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/CollectionResult.java
@@ -18,6 +18,7 @@
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
+import java.util.stream.Stream;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.equinox.internal.p2.metadata.expression.QueryResult;
@@ -68,4 +69,9 @@ public Set toUnmodifiableSet() {
public String toString() {
return collection.toString();
}
+
+ @Override
+ public Stream stream() {
+ return collection.stream();
+ }
}
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/Collector.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/Collector.java
index 25373f5bc9..6aa5f6658b 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/Collector.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/Collector.java
@@ -19,6 +19,7 @@
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
+import java.util.stream.Stream;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.equinox.internal.p2.metadata.Messages;
@@ -178,4 +179,9 @@ public Set toUnmodifiableSet() {
}
return Collections.unmodifiableSet(collected);
}
+
+ @Override
+ public Stream stream() {
+ return collected == null ? Stream.empty() : collected.stream();
+ }
}
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/IQueryResult.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/IQueryResult.java
index 3bb03e7a63..b2b2dd4f3f 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/IQueryResult.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/IQueryResult.java
@@ -14,8 +14,11 @@
******************************************************************************/
package org.eclipse.equinox.p2.query;
+import java.util.Collection;
import java.util.Iterator;
import java.util.Set;
+import java.util.stream.Stream;
+import java.util.stream.StreamSupport;
/**
* An IQueryResult represents the results of a query.
@@ -63,4 +66,18 @@ public interface IQueryResult extends IQueryable, Iterable {
* @return A Set backed by this query result.
*/
Set toUnmodifiableSet();
+
+ /**
+ * Returns a sequential {@code Stream} of the collected objects.
+ *
+ * @implSpec The default implementation creates a sequential {@code Stream} from
+ * this query-results {@code Spliterator}. Implementations backed by a
+ * {@code Collection} should override this method and call
+ * {@link Collection#stream()}.
+ * @since 2.7
+ */
+ default Stream stream() {
+ return StreamSupport.stream(spliterator(), false);
+ }
+
}