Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/PredicateIterator.java')
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/PredicateIterator.java39
1 files changed, 39 insertions, 0 deletions
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/PredicateIterator.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/PredicateIterator.java
new file mode 100644
index 0000000000..2a4b1a90d7
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/PredicateIterator.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.util.collection;
+
+import java.util.Iterator;
+
+/**
+ * @author Eike Stepper
+ * @since 3.3
+ */
+public class PredicateIterator<T> extends AbstractFilteredIterator<T>
+{
+ private final Predicate<? super T> predicate;
+
+ public PredicateIterator(Iterator<T> delegate, Predicate<? super T> predicate)
+ {
+ super(delegate);
+ this.predicate = predicate;
+ }
+
+ public Predicate<? super T> getPredicate()
+ {
+ return predicate;
+ }
+
+ @Override
+ protected boolean isValid(T element)
+ {
+ return predicate.apply(element);
+ }
+}

Back to the top