Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikael Barbero2016-12-14 16:13:56 +0000
committerMikaƫl Barbero2017-01-11 09:45:37 +0000
commitbaa04768e2b5e885a64ee9cd75fa63599ff74f14 (patch)
tree5468aab7e8a75778a9ce2e798d6cb3427ba8c216 /bundles/org.eclipse.equinox.common
parentc49e1155e09e7d358470d592f366eadf3598fe43 (diff)
downloadrt.equinox.bundles-baa04768e2b5e885a64ee9cd75fa63599ff74f14.tar.gz
rt.equinox.bundles-baa04768e2b5e885a64ee9cd75fa63599ff74f14.tar.xz
rt.equinox.bundles-baa04768e2b5e885a64ee9cd75fa63599ff74f14.zip
support Change-Id: Id0fa443eca4e9fd2c73ece6c0b5846715a38f043 Signed-off-by: Mikael Barbero <mikael@eclipse.org>
Diffstat (limited to 'bundles/org.eclipse.equinox.common')
-rw-r--r--bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ListenerList.java39
1 files changed, 37 insertions, 2 deletions
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ListenerList.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ListenerList.java
index 5444f0a5..5cb99425 100644
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ListenerList.java
+++ b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ListenerList.java
@@ -7,11 +7,13 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Mikael Barbero (Eclipse Foundation) - Bug 509234
*******************************************************************************/
package org.eclipse.core.runtime;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
+import java.util.*;
+import java.util.stream.Stream;
+import java.util.stream.StreamSupport;
/**
* This class is a thread safe list that is designed for storing lists of listeners.
@@ -247,4 +249,37 @@ public class ListenerList<E> implements Iterable<E> {
public synchronized void clear() {
listeners = EmptyArray;
}
+
+ /**
+ * Returns a Spliterator covering the registered listeners.
+ * <p>
+ * The spliterator reports Spliterator.SIZED, Spliterator.SUBSIZED, Spliterator.ORDERED, and Spliterator.IMMUTABLE
+ *
+ * @return a spliterator for listeners
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public Spliterator<E> spliterator() {
+ return (Spliterator<E>) Arrays.spliterator(listeners);
+ }
+
+ /**
+ * Returns a sequential {@code Stream} over the registered listeners.
+ *
+ * @return a sequential {@code Stream} over the registered listeners.
+ * @since org.eclipse.equinox.common 3.9
+ */
+ public Stream<E> stream() {
+ return StreamSupport.stream(spliterator(), false);
+ }
+
+ /**
+ * Returns a parallel {@code Stream} over the registered listeners.
+ *
+ * @return a parallel {@code Stream} over the registered listeners.
+ * @since org.eclipse.equinox.common 3.9
+ */
+ public Stream<E> parallelStream() {
+ return StreamSupport.stream(spliterator(), true);
+ }
}

Back to the top