jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cla...@apache.org
Subject [06/50] [abbrv] jena git commit: JENA-929: Migrate Filter to Java 8 Predicate
Date Sat, 16 May 2015 08:58:48 GMT
JENA-929: Migrate Filter to Java 8 Predicate

This closes #55


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/b2a1953b
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/b2a1953b
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/b2a1953b

Branch: refs/heads/add-contract-tests
Commit: b2a1953b9dc50babbafafed6dfedcdec2b465ee4
Parents: 08355d2
Author: ajs6f <ajs6f@virginia.edu>
Authored: Fri May 1 12:20:17 2015 -0400
Committer: Andy Seaborne <andy@apache.org>
Committed: Mon May 4 18:04:17 2015 +0100

----------------------------------------------------------------------
 .../apache/jena/sparql/graph/GraphMemPlain.java |   6 +-
 .../sparql/util/graph/GraphContainerUtils.java  |   6 +-
 .../main/java/org/apache/jena/graph/Triple.java |  26 ++-
 .../jena/graph/compose/CompositionBase.java     |  47 ++----
 .../apache/jena/graph/impl/CollectionGraph.java |  21 +--
 .../apache/jena/graph/impl/GraphMatcher.java    |  34 ++--
 .../org/apache/jena/mem/NodeToTriplesMap.java   |  25 ++-
 .../apache/jena/mem/NodeToTriplesMapMem.java    |  11 +-
 .../java/org/apache/jena/ontology/OntTools.java |   8 +-
 .../apache/jena/ontology/impl/OntClassImpl.java |  14 +-
 .../apache/jena/ontology/impl/OntModelImpl.java |  33 +---
 .../jena/ontology/impl/OntPropertyImpl.java     |  14 +-
 .../jena/ontology/impl/OntResourceImpl.java     |  17 +-
 .../org/apache/jena/rdf/model/Selector.java     |   9 +-
 .../apache/jena/rdf/model/impl/ModelCom.java    |  70 +++-----
 .../apache/jena/rdf/model/impl/ReifierStd.java  |  10 +-
 .../jena/rdfxml/xmloutput/impl/Unparser.java    |  69 ++++----
 .../jena/reasoner/rulesys/FBRuleInfGraph.java   |   5 +-
 .../apache/jena/reasoner/rulesys/Functor.java   |   9 +-
 .../jena/reasoner/rulesys/impl/SafeGraph.java   |  11 +-
 .../jena/util/iterator/ExtendedIterator.java    |   5 +-
 .../org/apache/jena/util/iterator/Filter.java   | 165 ++++++++++++-------
 .../jena/util/iterator/FilterDropIterator.java  |  34 ----
 .../jena/util/iterator/FilterIterator.java      |  14 +-
 .../jena/util/iterator/FilterKeepIterator.java  |  34 ----
 .../apache/jena/util/iterator/LazyIterator.java |   5 +-
 .../apache/jena/util/iterator/NiceIterator.java |   9 +-
 .../apache/jena/util/iterator/UniqueFilter.java |   5 +-
 .../apache/jena/graph/test/TestTripleField.java |  23 +--
 .../apache/jena/ontology/impl/TestOntTools.java |   5 +-
 .../jena/util/iterator/test/TestFilters.java    |  82 +--------
 .../propertytable/graph/GraphPropertyTable.java |  10 +-
 .../model/impl/SecuredModelImpl.java            |  12 +-
 .../model/impl/SecuredNodeIterator.java         |   6 +-
 .../model/impl/SecuredRSIterator.java           |  10 +-
 .../model/impl/SecuredResIterator.java          |   6 +-
 .../permissions/model/impl/SecuredSeqImpl.java  |   7 +-
 .../model/impl/SecuredStatementIterator.java    |   6 +-
 .../jena/permissions/utils/ContainerFilter.java |   7 +-
 .../permissions/utils/PermStatementFilter.java  |   6 +-
 .../permissions/utils/PermTripleFilter.java     |   6 +-
 .../permissions/utils/RDFListSecFilter.java     |   6 +-
 42 files changed, 338 insertions(+), 570 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/b2a1953b/jena-arq/src/main/java/org/apache/jena/sparql/graph/GraphMemPlain.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/graph/GraphMemPlain.java b/jena-arq/src/main/java/org/apache/jena/sparql/graph/GraphMemPlain.java
index bd8fd10..8630b8b 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/graph/GraphMemPlain.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/graph/GraphMemPlain.java
@@ -22,6 +22,7 @@ import java.util.HashSet ;
 import java.util.Iterator ;
 import java.util.Locale ;
 import java.util.Set ;
+import java.util.function.Predicate;
 
 import org.apache.jena.graph.Capabilities ;
 import org.apache.jena.graph.Node ;
@@ -31,7 +32,6 @@ import org.apache.jena.graph.impl.GraphBase ;
 import org.apache.jena.graph.impl.SimpleEventManager ;
 import org.apache.jena.util.iterator.ClosableIterator ;
 import org.apache.jena.util.iterator.ExtendedIterator ;
-import org.apache.jena.util.iterator.Filter ;
 
 /**
  * A version of Graph that does term equality only 
@@ -114,7 +114,7 @@ public class GraphMemPlain extends GraphBase
         return node ; 
     }
     
-    static class TripleMatchFilterEquality extends Filter<Triple>
+    static class TripleMatchFilterEquality implements Predicate<Triple>
     {
         final protected Triple tMatch;
     
@@ -123,7 +123,7 @@ public class GraphMemPlain extends GraphBase
             { this.tMatch = tMatch; }
         
         @Override
-        public boolean accept(Triple t)
+        public boolean test(Triple t)
         {
             return tripleContained(tMatch, t) ;
         }

http://git-wip-us.apache.org/repos/asf/jena/blob/b2a1953b/jena-arq/src/main/java/org/apache/jena/sparql/util/graph/GraphContainerUtils.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/util/graph/GraphContainerUtils.java b/jena-arq/src/main/java/org/apache/jena/sparql/util/graph/GraphContainerUtils.java
index f35fb25..c3ea9e6 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/util/graph/GraphContainerUtils.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/util/graph/GraphContainerUtils.java
@@ -22,6 +22,7 @@ import java.util.Collection ;
 import java.util.Iterator ;
 import java.util.SortedMap ;
 import java.util.TreeMap ;
+import java.util.function.Predicate;
 import java.util.regex.Matcher ;
 import java.util.regex.Pattern ;
 
@@ -31,7 +32,6 @@ import org.apache.jena.graph.Node ;
 import org.apache.jena.graph.Triple ;
 import org.apache.jena.sparql.expr.Expr ;
 import org.apache.jena.util.iterator.ExtendedIterator ;
-import org.apache.jena.util.iterator.Filter ;
 import org.apache.jena.vocabulary.RDF ;
 import org.apache.jena.vocabulary.RDFS ;
 
@@ -98,9 +98,9 @@ public class GraphContainerUtils
     }
     
     private static Node RDFSmember = RDFS.member.asNode() ;
-    private static Filter<Triple> filterRDFSmember = new Filter<Triple>() {
+    private static Predicate<Triple> filterRDFSmember = new Predicate<Triple>() {
         @Override
-        public boolean accept(Triple triple) {
+        public boolean test(Triple triple) {
             Node p = triple.getPredicate() ;
             if ( ! triple.getPredicate().isURI() )
                 return false ;

http://git-wip-us.apache.org/repos/asf/jena/blob/b2a1953b/jena-core/src/main/java/org/apache/jena/graph/Triple.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/graph/Triple.java b/jena-core/src/main/java/org/apache/jena/graph/Triple.java
index 89d7238..ee3f0e2 100644
--- a/jena-core/src/main/java/org/apache/jena/graph/Triple.java
+++ b/jena-core/src/main/java/org/apache/jena/graph/Triple.java
@@ -18,9 +18,10 @@
 
 package org.apache.jena.graph;
 
+import java.util.function.Predicate;
+
 import org.apache.jena.shared.PrefixMapping ;
 import org.apache.jena.util.iterator.ExtendedIterator ;
-import org.apache.jena.util.iterator.Filter ;
 import org.apache.jena.util.iterator.NullIterator ;
 
 /**
@@ -173,23 +174,22 @@ public class Triple
         {
         public abstract Node getField( Triple t );
         
-        public abstract Filter<Triple> filterOn( Node n );
+        public abstract Predicate<Triple> filterOn( Node n );
         
-        public final Filter<Triple> filterOn( Triple t )
+        public final Predicate<Triple> filterOn( Triple t )
             { return filterOn( getField( t ) ); }
         
-        protected static final Filter<Triple> anyTriple = Filter.any();
+        protected static final Predicate<Triple> anyTriple = t -> true;
         
         public static final Field fieldSubject = new Field() 
             { 
             @Override public Node getField( Triple t ) 
                 { return t.subj; }
             
-            @Override public Filter<Triple> filterOn( final Node n )
+            @Override public Predicate<Triple> filterOn( final Node n )
                 { 
                 return n.isConcrete() 
-                    ? new Filter<Triple>() 
-                        { @Override public boolean accept( Triple x ) { return n.equals( x.subj ); } }
+                    ? x -> n.equals( x.subj )
                     : anyTriple
                     ;
                 }
@@ -200,11 +200,9 @@ public class Triple
             @Override public Node getField( Triple t ) 
                 { return t.obj; } 
             
-            @Override public Filter<Triple> filterOn( final Node n )
+            @Override public Predicate<Triple> filterOn( final Node n )
                 { return n.isConcrete() 
-                    ? new Filter<Triple>() 
-                        { @Override public boolean accept( Triple x ) 
-                            { return n.sameValueAs( x.obj ); } }
+                    ? x -> n.sameValueAs( x.obj )
                     : anyTriple; 
                 }
             };
@@ -214,11 +212,9 @@ public class Triple
             @Override public Node getField( Triple t ) 
                 { return t.pred; } 
             
-            @Override public Filter<Triple> filterOn( final Node n )
+            @Override public Predicate<Triple> filterOn( final Node n )
                 { return n.isConcrete()
-                    ? new Filter<Triple>() 
-                        { @Override
-                        public boolean accept( Triple x ) { return n.equals( x.pred ); } }
+                    ? x -> n.equals( x.pred )
                     : anyTriple; 
                 }
             };

http://git-wip-us.apache.org/repos/asf/jena/blob/b2a1953b/jena-core/src/main/java/org/apache/jena/graph/compose/CompositionBase.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/graph/compose/CompositionBase.java b/jena-core/src/main/java/org/apache/jena/graph/compose/CompositionBase.java
index 7c02bca..a28fec4 100755
--- a/jena-core/src/main/java/org/apache/jena/graph/compose/CompositionBase.java
+++ b/jena-core/src/main/java/org/apache/jena/graph/compose/CompositionBase.java
@@ -24,6 +24,7 @@ package org.apache.jena.graph.compose;
 // Imports
 ///////////////
 import java.util.*;
+import java.util.function.Predicate;
 
 import org.apache.jena.graph.* ;
 import org.apache.jena.graph.impl.* ;
@@ -42,18 +43,17 @@ public abstract class CompositionBase extends GraphBase
 {
     /**
      * <p>
-     * Answer a {@link Filter} that will reject any element that is a member of iterator i.
+     * Answer a {@link Predicate} that will reject any element that is a member of iterator i.
      * As a side-effect, i will be closed. 
      * </p>
      * 
      * @param i A closable iterator
-     * @return A Filter that will accept any object not a member of i.
+     * @return A Predicate that will accept any object not a member of i.
      */
-    public static <T> Filter<T> reject( final ClosableIterator<? extends T> i )
+    public static <T> Predicate<T> reject( final ClosableIterator<? extends T> i )
         {
         final Set< ? extends T> suppress = IteratorCollection.iteratorToSet( i );
-        return new Filter<T>()
-            { @Override public boolean accept( T o ) { return !suppress.contains( o ); } };
+        return o -> !suppress.contains( o );
         }
         
     /**
@@ -117,10 +117,7 @@ public abstract class CompositionBase extends GraphBase
      */
     public static ExtendedIterator<Triple> rejecting( final ExtendedIterator<Triple> i, final Set<Triple> seen )
         {
-        Filter<Triple> seenFilter = new Filter<Triple>()
-            { @Override
-            public boolean accept( Triple x ) { return seen.contains( x ); } };
-        return i.filterDrop( seenFilter );
+        return i.filterDrop( seen::contains );
         }
         
     /**
@@ -129,50 +126,36 @@ public abstract class CompositionBase extends GraphBase
     */
     public static ExtendedIterator<Triple> rejecting( final ExtendedIterator<Triple> i, final Graph seen )
         {
-        Filter<Triple> seenFilter = new Filter<Triple>()
-            { @Override public boolean accept( Triple x ) { return seen.contains( x ); } };
-        return i.filterDrop( seenFilter );
+        return i.filterDrop( seen::contains );
         }
   
     /**
      * <p>
-     * Answer a {@link Filter} that will accept any object that is an element of 
+     * Answer a {@link Predicate} that will accept any object that is an element of 
      * iterator i.  As a side-effect, i will be evaluated and closed. 
      * </p>
      * 
      * @param i A closable iterator 
-     * @return A Filter that will accept any object in iterator i.
+     * @return A Predicate that will accept any object in iterator i.
      */
-    public static <T> Filter<T> ifIn( final ClosableIterator<T> i )
+    public static <T> Predicate<T> ifIn( final ClosableIterator<T> i )
         {
         final Set<T> allow = IteratorCollection.iteratorToSet( i );
-        return new Filter<T>()
-            { @Override public boolean accept( T x ) { return allow.contains( x ); } };
+        return allow::contains;
         }
         
     /**
      * <p>
-     * Answer a {@link Filter} that will accept any triple that is an edge of 
+     * Answer a {@link Predicate} that will accept any triple that is an edge of 
      * graph g. 
      * </p>
      * 
      * @param g A graph 
-     * @return A Filter that will accept any triple that is an edge in g.
+     * @return A Predicate that will accept any triple that is an edge in g.
      */
-    public static Filter<Triple> ifIn( final Graph g )
+    public static Predicate<Triple> ifIn( final Graph g )
         {
-        return new Filter<Triple>()
-            { @Override public boolean accept( Triple x ) { return g.contains( x ); } };
+        return g::contains;
         }
         
-
-    // Internal implementation methods
-    //////////////////////////////////
-
-
-    //==============================================================================
-    // Inner class definitions
-    //==============================================================================
-
-
 }

http://git-wip-us.apache.org/repos/asf/jena/blob/b2a1953b/jena-core/src/main/java/org/apache/jena/graph/impl/CollectionGraph.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/graph/impl/CollectionGraph.java b/jena-core/src/main/java/org/apache/jena/graph/impl/CollectionGraph.java
index 8fd02f8..f20e41f 100644
--- a/jena-core/src/main/java/org/apache/jena/graph/impl/CollectionGraph.java
+++ b/jena-core/src/main/java/org/apache/jena/graph/impl/CollectionGraph.java
@@ -21,13 +21,11 @@ import java.util.Collection ;
 import java.util.HashSet ;
 import java.util.Locale ;
 import java.util.Set ;
-
 import org.apache.jena.graph.Capabilities ;
 import org.apache.jena.graph.Node ;
 import org.apache.jena.graph.NodeFactory ;
 import org.apache.jena.graph.Triple ;
 import org.apache.jena.util.iterator.ExtendedIterator ;
-import org.apache.jena.util.iterator.Filter ;
 import org.apache.jena.util.iterator.WrappedIterator ;
 
 /**
@@ -64,21 +62,6 @@ public class CollectionGraph extends GraphBase
 		
 	};
 	
-	static class TripleMatchFilterEquality extends Filter<Triple>
-    {
-        final protected Triple tMatch;
-    
-        /** Creates new TripleMatchFilter */
-        public TripleMatchFilterEquality(Triple tMatch) 
-            { this.tMatch = tMatch; }
-        
-        @Override
-        public boolean accept(Triple t)
-        {
-            return tripleContained(tMatch, t) ;
-        }
-        
-    }
 	static boolean tripleContained(Triple patternTriple, Triple dataTriple)
     {
         return
@@ -122,7 +105,7 @@ public class CollectionGraph extends GraphBase
 	 */
 	public CollectionGraph()
 	{
-		this(new HashSet<Triple>(), true);
+		this(new HashSet<>(), true);
 	}
 
 	/**
@@ -163,7 +146,7 @@ public class CollectionGraph extends GraphBase
 		{
 			iter = WrappedIterator.createNoRemove( triples.iterator() );
 		}
-		return iter.filterKeep ( new TripleMatchFilterEquality( m ) );
+		return iter.filterKeep ( t -> tripleContained(m, t) );
 	}
 
 	@Override

http://git-wip-us.apache.org/repos/asf/jena/blob/b2a1953b/jena-core/src/main/java/org/apache/jena/graph/impl/GraphMatcher.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/graph/impl/GraphMatcher.java b/jena-core/src/main/java/org/apache/jena/graph/impl/GraphMatcher.java
index 6268283..55c9f85 100644
--- a/jena-core/src/main/java/org/apache/jena/graph/impl/GraphMatcher.java
+++ b/jena-core/src/main/java/org/apache/jena/graph/impl/GraphMatcher.java
@@ -17,6 +17,8 @@
  */
 
 package org.apache.jena.graph.impl;
+import static org.apache.jena.util.iterator.WrappedIterator.create;
+
 import java.util.*;
 
 import org.apache.jena.graph.* ;
@@ -256,25 +258,19 @@ public class GraphMatcher extends java.lang.Object {
         // Otherwise if some member of the bucket has friends
         // we can refine the hash, and we set refinableHash.
         check(HASH_OK);
-        return new FilterIterator<>(
-        new Filter<Bucket>() {
-            @Override public boolean accept(Bucket o) {
-                Bucket b = o;
-                if (b.size()==1)
-                    return true;
-                if (!refinableHash) {
-                    Iterator<AnonResource> it = b.members();
-                    while ( it.hasNext() )
-                        if (!it.next()
-                        .friends.isEmpty()) {
-                            refinableHash = true;
-                            break;
-                        }
-                }
-                return false;
-            }
-        },table.values().iterator());
-        
+		return create(table.values().iterator()).filterKeep(b -> {
+			if (b.size() == 1)
+				return true;
+			if (!refinableHash) {
+				Iterator<AnonResource> it = b.members();
+				while (it.hasNext())
+					if (!it.next().friends.isEmpty()) {
+						refinableHash = true;
+						break;
+					}
+			}
+			return false;
+		});
     }
     private void unbindAll(Set<AnonResource> s)  {
         for ( AnonResource value : s )

http://git-wip-us.apache.org/repos/asf/jena/blob/b2a1953b/jena-core/src/main/java/org/apache/jena/mem/NodeToTriplesMap.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/mem/NodeToTriplesMap.java b/jena-core/src/main/java/org/apache/jena/mem/NodeToTriplesMap.java
index a31a186..3342241 100644
--- a/jena-core/src/main/java/org/apache/jena/mem/NodeToTriplesMap.java
+++ b/jena-core/src/main/java/org/apache/jena/mem/NodeToTriplesMap.java
@@ -18,7 +18,10 @@
 
 package org.apache.jena.mem;
 
+import static org.apache.jena.util.iterator.WrappedIterator.create;
+
 import java.util.*;
+import java.util.function.Predicate;
 
 import org.apache.jena.graph.* ;
 import org.apache.jena.graph.Triple.* ;
@@ -106,24 +109,18 @@ public class NodeToTriplesMap extends NodeToTriplesMapBase
             }
         }
     
-    public ExtendedIterator<Triple> iterateAll( Triple pattern )
-        {
-        return
-            indexField.filterOn( pattern )
-            .and( f2.filterOn( pattern ) )
-            .and( f3.filterOn( pattern ) )
-            .filterKeep( iterateAll() )
-            ;
-        }
+	public ExtendedIterator<Triple> iterateAll(Triple pattern) {
+		Predicate<Triple> filter = indexField.filterOn(pattern)
+				.and(f2.filterOn(pattern)).and(f3.filterOn(pattern));
+		return create(iterateAll()).filterKeep(filter);  
+	}
 
     @Override public ExtendedIterator<Triple> iterator( Node index, Node n2, Node n3 )
         {
         TripleBunch s = bunchMap.get( index.getIndexingValue() );
-        return s == null
-            ? NullIterator.<Triple>instance()
-            : f2.filterOn( n2 ).and( f3.filterOn( n3 ) )
-                .filterKeep( s.iterator() )
-            ;
+        if (s == null) return NullIterator.<Triple>instance();
+        final Predicate<Triple> filter = f2.filterOn( n2 ).and( f3.filterOn( n3 ) );
+        return create(s.iterator()).filterKeep(filter);    
         }
 
     /**

http://git-wip-us.apache.org/repos/asf/jena/blob/b2a1953b/jena-core/src/main/java/org/apache/jena/mem/NodeToTriplesMapMem.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/mem/NodeToTriplesMapMem.java b/jena-core/src/main/java/org/apache/jena/mem/NodeToTriplesMapMem.java
index 43e528e..107cf3b 100644
--- a/jena-core/src/main/java/org/apache/jena/mem/NodeToTriplesMapMem.java
+++ b/jena-core/src/main/java/org/apache/jena/mem/NodeToTriplesMapMem.java
@@ -18,7 +18,10 @@
 
 package org.apache.jena.mem;
 
+import static org.apache.jena.util.iterator.WrappedIterator.create;
+
 import java.util.Iterator ;
+import java.util.function.Predicate;
 
 import org.apache.jena.graph.Node ;
 import org.apache.jena.graph.Triple ;
@@ -122,11 +125,9 @@ public class NodeToTriplesMapMem extends NodeToTriplesMapBase
        Object indexValue = index.getIndexingValue();
        TripleBunch s = bunchMap.get( indexValue );
 //       System.err.println( ">> ntmf::iterator: " + (s == null ? (Object) "None" : s.getClass()) );
-       return s == null
-           ? NullIterator.<Triple>instance()
-           : f2.filterOn( n2 ).and( f3.filterOn( n3 ) )
-               .filterKeep( s.iterator( new NotifyMe( indexValue ) ) )
-           ;
+       if (s == null) return NullIterator.<Triple>instance();
+       final Predicate<Triple> filter = f2.filterOn( n2 ).and( f3.filterOn( n3 ) );
+       return create(s.iterator( new NotifyMe( indexValue ))).filterKeep(filter);
        }    
 
     protected TripleBunch get( Object index )

http://git-wip-us.apache.org/repos/asf/jena/blob/b2a1953b/jena-core/src/main/java/org/apache/jena/ontology/OntTools.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/ontology/OntTools.java b/jena-core/src/main/java/org/apache/jena/ontology/OntTools.java
index 594321a..bb3b2a3 100755
--- a/jena-core/src/main/java/org/apache/jena/ontology/OntTools.java
+++ b/jena-core/src/main/java/org/apache/jena/ontology/OntTools.java
@@ -24,10 +24,10 @@ package org.apache.jena.ontology;
 // Imports
 ///////////////
 import java.util.*;
+import java.util.function.Predicate;
 
 import org.apache.jena.rdf.model.* ;
 import org.apache.jena.shared.JenaException ;
-import org.apache.jena.util.iterator.Filter ;
 
 
 /**
@@ -152,7 +152,7 @@ public class OntTools
      * @return A path, consisting of a list of statements whose first subject is <code>start</code>,
      * and whose last object is <code>end</code>, or null if no such path exists.
      */
-    public static Path findShortestPath( Model m, Resource start, RDFNode end, Filter<Statement> onPath ) {
+    public static Path findShortestPath( Model m, Resource start, RDFNode end, Predicate<Statement> onPath ) {
         List<Path> bfs = new LinkedList<>();
         Set<Resource> seen = new HashSet<>();
 
@@ -585,7 +585,7 @@ public class OntTools
      * A filter which accepts statements whose predicate matches one of a collection
      * of predicates held by the filter object.
      */
-    public static class PredicatesFilter extends Filter<Statement>
+    public static class PredicatesFilter implements Predicate<Statement>
     {
         public Collection<Property> m_preds;
 
@@ -609,7 +609,7 @@ public class OntTools
             m_preds.add( pred );
         }
 
-        @Override public boolean accept( Statement s ) {
+        @Override public boolean test( Statement s ) {
             return m_preds.contains( s.getPredicate() );
         }
     }

http://git-wip-us.apache.org/repos/asf/jena/blob/b2a1953b/jena-core/src/main/java/org/apache/jena/ontology/impl/OntClassImpl.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/ontology/impl/OntClassImpl.java b/jena-core/src/main/java/org/apache/jena/ontology/impl/OntClassImpl.java
index 8397e1f..e2aae36 100644
--- a/jena-core/src/main/java/org/apache/jena/ontology/impl/OntClassImpl.java
+++ b/jena-core/src/main/java/org/apache/jena/ontology/impl/OntClassImpl.java
@@ -34,7 +34,6 @@ import org.apache.jena.ontology.* ;
 import org.apache.jena.rdf.model.* ;
 import org.apache.jena.reasoner.InfGraph ;
 import org.apache.jena.util.iterator.ExtendedIterator ;
-import org.apache.jena.util.iterator.Filter ;
 import org.apache.jena.util.iterator.UniqueFilter ;
 import org.apache.jena.util.iterator.WrappedIterator ;
 import org.apache.jena.vocabulary.OWL ;
@@ -72,7 +71,6 @@ public class OntClassImpl
      * Note: should not be invoked directly by user code: use
      * {@link org.apache.jena.rdf.model.RDFNode#as as()} instead.
      */
-    @SuppressWarnings("hiding")
     public static Implementation factory = new Implementation() {
         @Override
         public EnhNode wrap( Node n, EnhGraph eg ) {
@@ -177,7 +175,7 @@ public class OntClassImpl
     @Override
     public ExtendedIterator<OntClass> listSuperClasses( boolean direct ) {
         return listDirectPropertyValues( getProfile().SUB_CLASS_OF(), "SUB_CLASS_OF", OntClass.class, getProfile().SUB_CLASS_OF(), direct, false )
-                .filterDrop( new SingleEqualityFilter<OntClass>( this ) ).filterKeep( new UniqueFilter<OntClass>());
+                .filterDrop( this::equals ).filterKeep( new UniqueFilter<OntClass>());
     }
 
     /**
@@ -367,7 +365,7 @@ public class OntClassImpl
     @Override
     public ExtendedIterator<OntClass> listSubClasses( boolean direct ) {
         return listDirectPropertyValues( getProfile().SUB_CLASS_OF(), "SUB_CLASS_OF", OntClass.class, getProfile().SUB_CLASS_OF(), direct, true )
-                .filterDrop( new SingleEqualityFilter<OntClass>( this ) ).filterKeep( new UniqueFilter<OntClass>());
+                .filterDrop( this::equals ).filterKeep( new UniqueFilter<OntClass>());
     }
 
 
@@ -670,12 +668,8 @@ public class OntClassImpl
         return getModel()
                 .listStatements( null, RDF.type, this )
                 .mapWith( s -> s.getSubject().as( Individual.class ) )
-                .filterKeep( new Filter<Individual>() {
-                    @Override
-                    public boolean accept( Individual o ) {
-                        // if direct, ignore the sub-class typed resources
-                        return o.hasRDFType( OntClassImpl.this, direct );
-                    }} ).filterKeep( new UniqueFilter<Individual>());
+                .filterKeep( o -> o.hasRDFType( OntClassImpl.this, direct ))
+                .filterKeep( new UniqueFilter<Individual>());
     }
 
 

http://git-wip-us.apache.org/repos/asf/jena/blob/b2a1953b/jena-core/src/main/java/org/apache/jena/ontology/impl/OntModelImpl.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/ontology/impl/OntModelImpl.java b/jena-core/src/main/java/org/apache/jena/ontology/impl/OntModelImpl.java
index 458a945..0aac74a 100644
--- a/jena-core/src/main/java/org/apache/jena/ontology/impl/OntModelImpl.java
+++ b/jena-core/src/main/java/org/apache/jena/ontology/impl/OntModelImpl.java
@@ -28,6 +28,7 @@ import java.io.OutputStream ;
 import java.io.Reader ;
 import java.io.Writer ;
 import java.util.* ;
+import java.util.function.Predicate;
 
 import org.apache.jena.enhanced.BuiltinPersonalities ;
 import org.apache.jena.enhanced.EnhNode ;
@@ -536,17 +537,8 @@ public class OntModelImpl extends ModelCom implements OntModel
 
         // no easy shortcut, so we use brute force
         return listClasses()
-                 .filterDrop( new Filter<OntClass>() {
-                     @Override
-                    public boolean accept( OntClass o ) {
-                         return ((OntResource) o).isOntLanguageTerm();
-                     }} )
-                 .filterKeep( new Filter<OntClass>() {
-                     @Override
-                    public boolean accept( OntClass o ) {
-                         return o.isHierarchyRoot();
-                     }} )
-                    ;
+                 .filterDrop( OntResource::isOntLanguageTerm )
+                 .filterKeep( OntClass::isHierarchyRoot );
     }
 
 
@@ -658,14 +650,7 @@ public class OntModelImpl extends ModelCom implements OntModel
      */
     @Override
     public ExtendedIterator<OntClass> listNamedClasses() {
-        return listClasses().filterDrop(
-            new Filter<OntClass>() {
-                @Override
-                public boolean accept( OntClass x ) {
-                    return x.isAnon();
-                }
-            }
-        );
+        return listClasses().filterDrop( OntClass::isAnon );
     }
 
 
@@ -3112,13 +3097,13 @@ public class OntModelImpl extends ModelCom implements OntModel
     // Inner class definitions
     //==============================================================================
 
-    protected class NodeCanAs<T extends RDFNode> extends Filter<Node>
+    protected class NodeCanAs<T extends RDFNode> implements Predicate<Node>
     {
         protected Class<T> m_asKey;
         protected NodeCanAs( Class<T> asKey ) { m_asKey = asKey; }
 
         @Override
-        public boolean accept( Node x ) {
+        public boolean test( Node x ) {
                 try { getNodeAs( x, m_asKey );  }
                 catch (Exception ignore) { return false; }
         return true;
@@ -3127,14 +3112,14 @@ public class OntModelImpl extends ModelCom implements OntModel
 
     }
 
-    /** Filter that accepts nodes that can be mapped to the given facet */
-    protected class SubjectNodeCanAs<T extends RDFNode> extends Filter<T>
+    /** Predicate that accepts nodes that can be mapped to the given facet */
+    protected class SubjectNodeCanAs<T extends RDFNode> implements Predicate<T>
     {
         protected Class<T> m_asKey;
         protected SubjectNodeCanAs( Class<T> asKey ) { m_asKey = asKey; }
 
         @Override
-        public boolean accept( T x ) {
+        public boolean test( T x ) {
             Node n = (x instanceof Triple)
                     ? ((Triple) x).getSubject()
                     : ((x instanceof EnhNode) ? ((EnhNode) x).asNode() :  (Node) x);

http://git-wip-us.apache.org/repos/asf/jena/blob/b2a1953b/jena-core/src/main/java/org/apache/jena/ontology/impl/OntPropertyImpl.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/ontology/impl/OntPropertyImpl.java b/jena-core/src/main/java/org/apache/jena/ontology/impl/OntPropertyImpl.java
index 8d11a72..2280299 100644
--- a/jena-core/src/main/java/org/apache/jena/ontology/impl/OntPropertyImpl.java
+++ b/jena-core/src/main/java/org/apache/jena/ontology/impl/OntPropertyImpl.java
@@ -24,6 +24,7 @@ package org.apache.jena.ontology.impl;
 // Imports
 ///////////////
 import java.util.*;
+import java.util.function.Predicate;
 
 import org.apache.jena.enhanced.* ;
 import org.apache.jena.graph.* ;
@@ -53,7 +54,6 @@ public class OntPropertyImpl
      * Note: should not be invoked directly by user code: use
      * {@link org.apache.jena.rdf.model.RDFNode#as as()} instead.
      */
-    @SuppressWarnings("hiding")
     public static Implementation factory = new Implementation() {
         @Override
         public EnhNode wrap( Node n, EnhGraph eg ) {
@@ -175,7 +175,7 @@ public class OntPropertyImpl
     @Override
     public ExtendedIterator<OntProperty> listSuperProperties( boolean direct ) {
         return listDirectPropertyValues( getProfile().SUB_PROPERTY_OF(), "SUB_PROPERTY_OF", OntProperty.class, getProfile().SUB_PROPERTY_OF(), direct, false )
-                        .filterDrop( new SingleEqualityFilter<OntProperty>( this ) );
+                        .filterDrop( this::equals );
     }
 
     /**
@@ -835,11 +835,7 @@ public class OntPropertyImpl
                 // in the non-direct case, global properties appear in the ldp
                 // of all classes, but we ignore the built-in classes
                 return ((OntModel) getModel()).listClasses()
-                                              .filterDrop( new Filter<OntClass>() {
-                                                @Override
-                                                public boolean accept( OntClass c ) {
-                                                    return c.isOntLanguageTerm();
-                                                }} );
+                                              .filterDrop( OntClass::isOntLanguageTerm );
             }
             else {
                 // in the direct case, global properties only attach to the
@@ -902,7 +898,7 @@ public class OntPropertyImpl
      * <p>Filter that accepts classes which have the given property as one of
      * their declared properties.</p>
      */
-    private class FilterDeclaringClass extends Filter<OntClass>
+    private class FilterDeclaringClass implements Predicate<OntClass>
     {
         private boolean m_direct;
         private Property m_prop;
@@ -912,7 +908,7 @@ public class OntPropertyImpl
             m_direct = direct;
         }
 
-        @Override public boolean accept( OntClass o ) {
+        @Override public boolean test( OntClass o ) {
             return o.hasDeclaredProperty( m_prop, m_direct );
         }
 

http://git-wip-us.apache.org/repos/asf/jena/blob/b2a1953b/jena-core/src/main/java/org/apache/jena/ontology/impl/OntResourceImpl.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/ontology/impl/OntResourceImpl.java b/jena-core/src/main/java/org/apache/jena/ontology/impl/OntResourceImpl.java
index cdd18fe..97911de 100644
--- a/jena-core/src/main/java/org/apache/jena/ontology/impl/OntResourceImpl.java
+++ b/jena-core/src/main/java/org/apache/jena/ontology/impl/OntResourceImpl.java
@@ -25,6 +25,7 @@ package org.apache.jena.ontology.impl;
 ///////////////
 import java.util.*;
 import java.util.function.Function;
+import java.util.function.Predicate;
 
 import org.apache.jena.datatypes.xsd.XSDDatatype ;
 import org.apache.jena.enhanced.* ;
@@ -68,7 +69,6 @@ public class OntResourceImpl
      * Note: should not be invoked directly by user code: use
      * {@link org.apache.jena.rdf.model.RDFNode#as as()} instead.
      */
-    @SuppressWarnings("hiding")
     public static Implementation factory = new Implementation() {
         @Override
         public EnhNode wrap( Node n, EnhGraph eg ) {
@@ -1654,23 +1654,14 @@ public class OntResourceImpl
 
 
     /** Filter for matching language tags on the objects of statements */
-    protected class LangTagFilter extends Filter<Statement>
+    protected class LangTagFilter implements Predicate<Statement>
     {
         protected String m_lang;
         public LangTagFilter( String lang ) { m_lang = lang; }
         @Override
-        public boolean accept( Statement x ) {
+        public boolean test( Statement x ) {
             RDFNode o = x.getObject();
-            return o.isLiteral() && langTagMatch( m_lang, ((Literal) o).getLanguage() );
+            return o.isLiteral() && langTagMatch( m_lang, o.asLiteral().getLanguage() );
         }
     }
-
-    /** Filter for accepting only the given value, based on .equals() */
-    protected class SingleEqualityFilter<T>
-        extends Filter<T>
-    {
-        private T m_obj;
-        public SingleEqualityFilter( T x ) { m_obj = x; }
-        @Override public boolean accept( T x ) {return m_obj.equals( x );}
-    }
 }

http://git-wip-us.apache.org/repos/asf/jena/blob/b2a1953b/jena-core/src/main/java/org/apache/jena/rdf/model/Selector.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/rdf/model/Selector.java b/jena-core/src/main/java/org/apache/jena/rdf/model/Selector.java
index 7bf1125..415c596 100644
--- a/jena-core/src/main/java/org/apache/jena/rdf/model/Selector.java
+++ b/jena-core/src/main/java/org/apache/jena/rdf/model/Selector.java
@@ -18,6 +18,8 @@
 
 package org.apache.jena.rdf.model;
 
+import java.util.function.Predicate;
+
 /** A Statement selector.
  *
  * <p>Model includes list and query methods which will return all the
@@ -26,12 +28,7 @@ package org.apache.jena.rdf.model;
  *
 */
 
-public interface Selector {
-    /** Determine whether a Statement should be selected.
-     * @param s The statement to be considered.
-     * @return true if the statement has been selected.
-     */
-    boolean test( Statement s );
+public interface Selector extends Predicate<Statement> {
     
     /**
         Answer true iff this Selector is completely characterised by its subject,

http://git-wip-us.apache.org/repos/asf/jena/blob/b2a1953b/jena-core/src/main/java/org/apache/jena/rdf/model/impl/ModelCom.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/rdf/model/impl/ModelCom.java b/jena-core/src/main/java/org/apache/jena/rdf/model/impl/ModelCom.java
index a0ed407..e644f55 100644
--- a/jena-core/src/main/java/org/apache/jena/rdf/model/impl/ModelCom.java
+++ b/jena-core/src/main/java/org/apache/jena/rdf/model/impl/ModelCom.java
@@ -21,7 +21,6 @@ package org.apache.jena.rdf.model.impl;
 import java.io.* ;
 import java.net.URL ;
 import java.util.* ;
-
 import org.apache.jena.datatypes.DatatypeFormatException ;
 import org.apache.jena.datatypes.RDFDatatype ;
 import org.apache.jena.datatypes.TypeMapper ;
@@ -494,39 +493,34 @@ implements Model, PrefixMapping, Lock
         }
     }
     
-    private class StringFilteredStmtIterator extends FilterKeepIterator<Statement> implements StmtIterator {
-        public StringFilteredStmtIterator(final String str, Iterator<Statement> it ) {
-            super(
-                    new Filter<Statement>() {
-                        @Override public boolean accept(Statement s) {
-                            RDFNode o = s.getObject();
-                            if (o instanceof Literal) {
-                                if (str == null) return true; // should not happen
-                                return (str.equals(((Literal) o).getString()));
-                            } 
-                            return false;
-                        }
-              }, 
-              it );
-        }
+	private class StringFilteredStmtIterator extends FilterIterator<Statement>
+			implements StmtIterator {
+		public StringFilteredStmtIterator(final String str, Iterator<Statement> it) {
+			super(s -> {
+				RDFNode o = s.getObject();
+				if (o instanceof Literal) {
+					if (str == null)
+						return true; // should not happen
+				return (str.equals(o.asLiteral().getString()));
+			}
+			return false;
+		}, it);
+		}
         @Override public Statement nextStatement() { return next(); }
     }
     
-    private class LangFilteredStmtIterator extends FilterKeepIterator<Statement> implements StmtIterator {
-        public LangFilteredStmtIterator(final String l, Iterator<Statement> it ) {
-            super(
-                    new Filter<Statement>() {
-                        @Override public boolean accept(Statement s) {
-                            RDFNode o = s.getObject();
-                            if (o instanceof Literal) {
-                                if (l == null) return true;
-                                return (l.equals(((Literal) o).getLanguage()));
-                            } 
-                            return false;
-                        }
-              }, 
-              it );
-        }
+    private class LangFilteredStmtIterator extends FilterIterator<Statement> implements StmtIterator {
+		public LangFilteredStmtIterator(final String l, Iterator<Statement> it) {
+			super(s -> {
+				RDFNode o = s.getObject();
+				if (o instanceof Literal) {
+					if (l == null)
+						return true;
+					return (l.equals(o.asLiteral().getLanguage()));
+				}
+				return false;
+			}, it);
+		}
         @Override public Statement nextStatement() { return next(); }
     }
   
@@ -1286,22 +1280,10 @@ implements Model, PrefixMapping, Lock
         StmtIterator sts = IteratorFactory.asStmtIterator( findTriplesFrom( selector ), this );
         return selector.isSimple() 
             ? sts 
-            : new StmtIteratorImpl( sts .filterKeep ( asFilter( selector ) ) )
+            : new StmtIteratorImpl( sts .filterKeep ( selector ) )
         ;
     }
 
-    /**
-        Answer a Filter that filters exactly those things the Selector selects.
-
-        @param s a Selector on statements
-        @return a Filter that accepts statements that s passes tests on
-     */
-     public Filter<Statement> asFilter( final Selector s )
-     { return new Filter<Statement>()
-         { @Override public boolean accept( Statement x ) { return s.test( x ); } };
-     }
-
-
      /**
         Answer an [extended] iterator which returns the triples in this graph which
         are selected by the (S, P, O) triple in the selector, ignoring any special

http://git-wip-us.apache.org/repos/asf/jena/blob/b2a1953b/jena-core/src/main/java/org/apache/jena/rdf/model/impl/ReifierStd.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/rdf/model/impl/ReifierStd.java b/jena-core/src/main/java/org/apache/jena/rdf/model/impl/ReifierStd.java
index 5180d7a..0bf7d26 100644
--- a/jena-core/src/main/java/org/apache/jena/rdf/model/impl/ReifierStd.java
+++ b/jena-core/src/main/java/org/apache/jena/rdf/model/impl/ReifierStd.java
@@ -20,12 +20,12 @@ package org.apache.jena.rdf.model.impl;
 
 
 import java.util.* ;
+import java.util.function.Predicate;
 
 import org.apache.jena.graph.* ;
 import org.apache.jena.shared.AlreadyReifiedException ;
 import org.apache.jena.shared.CannotReifyException ;
 import org.apache.jena.util.iterator.ExtendedIterator ;
-import org.apache.jena.util.iterator.Filter ;
 import org.apache.jena.util.iterator.NullIterator ;
 import org.apache.jena.util.iterator.WrappedIterator ;
 import org.apache.jena.vocabulary.RDF ;
@@ -60,16 +60,10 @@ public class ReifierStd
             return graph.find(match) ;
     }
     
-    static Filter<Triple> filterReif = new Filter<Triple>() {
-        @Override
-        public boolean accept(Triple triple)
-        {
-            return triple.getPredicate().equals(subject) ||
+    static Predicate<Triple> filterReif = triple -> triple.getPredicate().equals(subject) ||
                    triple.getPredicate().equals(predicate) ||
                    triple.getPredicate().equals(object) ||
                    ( triple.getPredicate().equals(rdfType) && triple.getObject().equals(statement) ) ;
-        }
-    } ; 
 
     /**
         Answer an iterator over all the reification triples that this Reifier exposes

http://git-wip-us.apache.org/repos/asf/jena/blob/b2a1953b/jena-core/src/main/java/org/apache/jena/rdfxml/xmloutput/impl/Unparser.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/rdfxml/xmloutput/impl/Unparser.java b/jena-core/src/main/java/org/apache/jena/rdfxml/xmloutput/impl/Unparser.java
index 409bbd9..8e6d765 100644
--- a/jena-core/src/main/java/org/apache/jena/rdfxml/xmloutput/impl/Unparser.java
+++ b/jena-core/src/main/java/org/apache/jena/rdfxml/xmloutput/impl/Unparser.java
@@ -115,6 +115,8 @@ package org.apache.jena.rdfxml.xmloutput.impl;
  * 
  * [6.34] literal ::= (any well-formed XML)
  */
+import static org.apache.jena.util.iterator.WrappedIterator.create;
+
 import java.io.PrintWriter ;
 import java.util.* ;
 
@@ -1542,12 +1544,12 @@ class Unparser {
      * This class is an iterator over the set infinite, but we wait until it is
      * used before instantiating the underlying iterator.
      */
-    private Iterator<Resource> allInfiniteLeft() {
-        return new LateBindingIterator<Resource>() {
+    private ExtendedIterator<Resource> allInfiniteLeft() {
+        return create(new LateBindingIterator<Resource>() {
             @Override public Iterator<Resource> create() {
                 return infinite.iterator();
             }
-        };
+        });
     }
 
     private Iterator<Resource> pleasingTypeIterator() {
@@ -1630,13 +1632,14 @@ class Unparser {
 
         // Subjects that are not objects of anything.
 //        Iterator<Resource> nonObjects = new FilterIterator<Resource>(new Filter<Resource>() {
-//            @Override public boolean accept( Resource o ) {
+//            @Override public boolean test( Resource o ) {
 //                return (!objectTable.containsKey(o))
 //                        && (!wantReification(o));
 //            }
 //        }, modelListSubjects());
-        Iterator<Resource> nonObjects = modelListSubjects().filterKeep( new Filter<Resource>() {@Override public boolean accept( Resource o ) { return (!objectTable.containsKey(o))  && (!wantReification(o) ); } } );
-        
+		Iterator<Resource> nonObjects = modelListSubjects()
+				.filterKeep( o -> !objectTable.containsKey(o) && !wantReification(o));
+
         // At these stage we evaluate a dependency graph of the remaining
         // resources.
         // This is stuck in the master iterator so that it's hasNext is called
@@ -1652,26 +1655,22 @@ class Unparser {
         };
         // non-anonymous resources that are the object of more than one
         // triple that are in infinite cycles.
-        Iterator<Resource> firstChoiceCyclic = new FilterIterator<>(new Filter<Resource>() {
-            @Override
-            public boolean accept(Resource r) {
-                codeCoverage[4]++;
-                if (r.isAnon())
-                    return false;
-                Integer cnt = objectTable.get(r);
-                if (cnt == null || cnt.intValue() <= 1)
-                    return false;
-                return true;
-            }
-        }, this.allInfiniteLeft());
+		Iterator<Resource> firstChoiceCyclic = allInfiniteLeft()
+				.filterKeep(r -> {
+					codeCoverage[4]++;
+					if (r.isAnon())
+						return false;
+					Integer cnt = objectTable.get(r);
+					if (cnt == null || cnt.intValue() <= 1)
+						return false;
+					return true;
+				});
         // any non genuinely anonymous resources that are in infinite cycles
-        Iterator<Resource> nonAnonInfinite = new FilterIterator<>(new Filter<Resource>() {
-            @Override
-            public boolean accept(Resource r) {
-                codeCoverage[5]++;
-                return !isGenuineAnon(r);
-            }
-        }, allInfiniteLeft());
+		Iterator<Resource> nonAnonInfinite = allInfiniteLeft()
+				.filterKeep(r -> {
+					codeCoverage[5]++;
+					return !isGenuineAnon(r);
+				});
         // any other resource in an infinite cyle
         Iterator<Resource> inf = allInfiniteLeft();
         Iterator<Resource> anotherFake = new NullIterator<Resource>() {
@@ -1681,13 +1680,10 @@ class Unparser {
                 return false;
             }
         };
-        Iterator<Resource> reifications = new FilterIterator<>(new Filter<Resource>() {
-            @Override
-            public boolean accept(Resource r) {
-                codeCoverage[6]++;
-                return res2statement.containsKey(r);
-            }
-        }, allInfiniteLeft());
+		Iterator<Resource> reifications = allInfiniteLeft().filterKeep(r -> {
+			codeCoverage[6]++;
+			return res2statement.containsKey(r);
+		});
         // any other resource.
         Iterator<Resource> backStop = modelListSubjects();
 
@@ -1703,15 +1699,10 @@ class Unparser {
                                 return false;
                             }
                         }, backStop };
-        Iterator<Resource> allAsOne = WrappedIterator.createIteratorIterator( Arrays.asList(all).iterator() );
+        ExtendedIterator<Resource> allAsOne = WrappedIterator.createIteratorIterator( Arrays.asList(all).iterator() );
         		
         // Filter for those that still have something to list.
-        return new FilterIterator<>(new Filter<Resource>() {
-            @Override
-            public boolean accept(Resource r) {
-                return hasProperties(r);
-            }
-        }, allAsOne);
+        return allAsOne.filterKeep(this::hasProperties);
     }
 
     private Set<ResIterator> openResIterators = new HashSet<>();

http://git-wip-us.apache.org/repos/asf/jena/blob/b2a1953b/jena-core/src/main/java/org/apache/jena/reasoner/rulesys/FBRuleInfGraph.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/reasoner/rulesys/FBRuleInfGraph.java b/jena-core/src/main/java/org/apache/jena/reasoner/rulesys/FBRuleInfGraph.java
index 6aa6a85..34f2e72 100644
--- a/jena-core/src/main/java/org/apache/jena/reasoner/rulesys/FBRuleInfGraph.java
+++ b/jena-core/src/main/java/org/apache/jena/reasoner/rulesys/FBRuleInfGraph.java
@@ -36,7 +36,6 @@ import org.apache.jena.shared.impl.JenaParameters ;
 import org.apache.jena.util.OneToManyMap ;
 import org.apache.jena.util.PrintUtil ;
 import org.apache.jena.util.iterator.ExtendedIterator ;
-import org.apache.jena.util.iterator.Filter ;
 import org.apache.jena.util.iterator.UniqueFilter ;
 import org.apache.jena.vocabulary.RDFS ;
 import org.apache.jena.vocabulary.ReasonerVocabulary ;
@@ -562,9 +561,7 @@ public class FBRuleInfGraph  extends BasicForwardRuleInfGraph implements Backwar
         }
         if (filterFunctors) {
 //            return result.filterDrop(Functor.acceptFilter);
-            return result.filterDrop( new Filter<Triple>() {
-                @Override public boolean accept( Triple o )
-                    { return FBRuleInfGraph.this.accept( o ); }} );
+            return result.filterDrop( t -> FBRuleInfGraph.this.accept( t ) );
         } else {
             return result;
         }

http://git-wip-us.apache.org/repos/asf/jena/blob/b2a1953b/jena-core/src/main/java/org/apache/jena/reasoner/rulesys/Functor.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/reasoner/rulesys/Functor.java b/jena-core/src/main/java/org/apache/jena/reasoner/rulesys/Functor.java
index b6054cf..27217e6 100755
--- a/jena-core/src/main/java/org/apache/jena/reasoner/rulesys/Functor.java
+++ b/jena-core/src/main/java/org/apache/jena/reasoner/rulesys/Functor.java
@@ -21,11 +21,11 @@ package org.apache.jena.reasoner.rulesys;
 import org.apache.jena.datatypes.* ;
 import org.apache.jena.graph.* ;
 import org.apache.jena.util.PrintUtil ;
-import org.apache.jena.util.iterator.Filter ;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.util.*;
+import java.util.function.Predicate;
 
 /**
  * A functor comprises a functor name and a list of 
@@ -46,14 +46,11 @@ public class Functor implements ClauseEntry {
     /** A built in that implements the functor */
     protected Builtin implementor;
     
-    /** A static Filter instance that detects triples with Functor objects */
-    public static final Filter<Triple> acceptFilter = new Filter<Triple>() {
-                @Override
-                public boolean accept( Triple t) {
+    /** A static Predicate instance that detects triples with Functor objects */
+    public static final Predicate<Triple> acceptFilter = t ->  {
                     if (t.getSubject().isLiteral()) return true;
                     Node n = t.getObject();
                     return n.isLiteral() && n.getLiteralDatatype() == FunctorDatatype.theFunctorDatatype;
-                }
             };
     
     protected static Logger logger = LoggerFactory.getLogger(Functor.class);

http://git-wip-us.apache.org/repos/asf/jena/blob/b2a1953b/jena-core/src/main/java/org/apache/jena/reasoner/rulesys/impl/SafeGraph.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/reasoner/rulesys/impl/SafeGraph.java b/jena-core/src/main/java/org/apache/jena/reasoner/rulesys/impl/SafeGraph.java
index 8a545fa..cc05561 100644
--- a/jena-core/src/main/java/org/apache/jena/reasoner/rulesys/impl/SafeGraph.java
+++ b/jena-core/src/main/java/org/apache/jena/reasoner/rulesys/impl/SafeGraph.java
@@ -24,7 +24,6 @@ import org.apache.jena.graph.Triple ;
 import org.apache.jena.graph.impl.SimpleEventManager ;
 import org.apache.jena.graph.impl.WrappedGraph ;
 import org.apache.jena.util.iterator.ExtendedIterator ;
-import org.apache.jena.util.iterator.Filter ;
 
 /**
  * A SafeGraph wraps a graph which might contain generalized RDF
@@ -46,14 +45,8 @@ public class SafeGraph extends WrappedGraph implements Graph {
     @Override
     public ExtendedIterator<Triple> find( Node s, Node p, Node o ) {
         return SimpleEventManager.notifyingRemove( this, 
-                base.find( s, p, o ).filterDrop( new Filter<Triple>() {
-                    @Override
-                    public boolean accept(Triple t) {
-                        if (t.getSubject().isLiteral()) return true;
-                        if (t.getPredicate().isBlank() || t.getPredicate().isLiteral()) return true;
-                        return false;
-                    }
-                } ) );
+                base.find( s, p, o ).filterDrop( t -> t.getSubject().isLiteral() ||
+                		t.getPredicate().isBlank() || t.getPredicate().isLiteral() ) );
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/jena/blob/b2a1953b/jena-core/src/main/java/org/apache/jena/util/iterator/ExtendedIterator.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/util/iterator/ExtendedIterator.java b/jena-core/src/main/java/org/apache/jena/util/iterator/ExtendedIterator.java
index 2a0eeb6..9953286 100644
--- a/jena-core/src/main/java/org/apache/jena/util/iterator/ExtendedIterator.java
+++ b/jena-core/src/main/java/org/apache/jena/util/iterator/ExtendedIterator.java
@@ -20,6 +20,7 @@ package org.apache.jena.util.iterator;
 
 import java.util.*;
 import java.util.function.Function;
+import java.util.function.Predicate;
 
 /**
     an ExtendedIterator is a ClosableIterator on which other operations are
@@ -54,14 +55,14 @@ public interface ExtendedIterator<T> extends ClosableIterator<T>
          pass the filter _f_. The order of the elements is preserved. Does not
          copy _this_, which is consumed as the result is consumed.
      */
-     public ExtendedIterator<T> filterKeep( Filter<T> f );
+     public ExtendedIterator<T> filterKeep( Predicate<T> f );
 
      /**
          return a new iterator containing only the elements of _this_ which
          are rejected by the filter _f_. The order of the elements is preserved.
          Does not copy _this_, which is consumed as the result is consumed.
      */
-     public ExtendedIterator<T> filterDrop( Filter<T> f );
+     public ExtendedIterator<T> filterDrop( Predicate<T> f );
 
      /**
          return a new iterator where each element is the result of applying

http://git-wip-us.apache.org/repos/asf/jena/blob/b2a1953b/jena-core/src/main/java/org/apache/jena/util/iterator/Filter.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/util/iterator/Filter.java b/jena-core/src/main/java/org/apache/jena/util/iterator/Filter.java
index 5c7faaf..6c85c28 100644
--- a/jena-core/src/main/java/org/apache/jena/util/iterator/Filter.java
+++ b/jena-core/src/main/java/org/apache/jena/util/iterator/Filter.java
@@ -19,66 +19,107 @@
 package org.apache.jena.util.iterator;
 
 import java.util.Iterator;
+import java.util.function.Predicate;
 
-/** 
-    boolean functions wrapped to be used in filtering iterators.
-*/
-public abstract class Filter<T>
-    {
-    /**
-        Answer true iff the object <code>o</code> is acceptable. This method
-        may also throw an exception if the argument is of a wrong type; it
-        is not required to return <code>false</code> in such a case.
-    */
-	public abstract boolean accept( T o );
-    
-    public ExtendedIterator<T> filterKeep( Iterator<T> it )
-        { return new FilterKeepIterator<>( this, it ); }
-    
-    public Filter<T> and( final Filter<T> other )
-        { return other.isAny() ? this : new Filter<T>()
-            { @Override public boolean accept( T x ) 
-                { return Filter.this.accept( x ) && other.accept( x ); } 
-            };
-        }
-    
-    /**
-        Answer true iff this filter will deliver true for any argument. Should never
-        be overridden except by classes generated by any() below.
-    */
-    public boolean isAny()
-        { return false; }
-    
-    /** 
-        A Filter that accepts everything it's offered.
-        @deprecated use Filter.any()
-    */
-    @SuppressWarnings({"unchecked", "rawtypes"})
-    // Knowingly suppressed - maximum backward compatibility. 
-    @Deprecated public static final Filter any = new Filter()
-        { 
-        @Override public final boolean isAny() { return true; }
-        
-        @Override public final boolean accept( Object o ) { return true; } 
-        
-        @Override public Filter and( Filter other ) { return other; }
-        
-        @Override public ExtendedIterator filterKeep( Iterator it )
-            { return WrappedIterator.create( it ); }
-        };
-        
-    public static <T> Filter<T> any() 
-        {  
-        return new Filter<T>()
-            {
-            @Override public final boolean isAny() { return true; }
-            
-            @Override public final boolean accept( T o ) { return true; } 
-            
-            @Override public Filter<T> and( Filter<T> other ) { return other; }
-            
-            @Override public ExtendedIterator<T> filterKeep( Iterator<T> it )
-                { return WrappedIterator.create( it ); }
-            };
-        }
-    }
+/**
+ * boolean functions wrapped to be used in filtering iterators.
+ * 
+ * Deprecated in favor of {@link Predicate}.
+ */
+@Deprecated
+public abstract class Filter<T> implements Predicate<T> {
+
+	public boolean test(T o) {
+		return accept(o);
+	}
+
+	@Deprecated
+	public abstract boolean accept(T o);
+
+	@Deprecated
+	public ExtendedIterator<T> filterKeep(Iterator<T> it) {
+		return new FilterIterator<>(this, it);
+	}
+
+	/**
+	 * Use {@link #and(Predicate)} instead.
+	 */
+	@Deprecated
+	public Filter<T> and(final Filter<T> other) {
+		return other.isAny() ? this : new Filter<T>() {
+			@Override
+			public boolean accept(T x) {
+				return Filter.this.accept(x) && other.accept(x);
+			}
+		};
+	}
+
+	/**
+	 * Answer true iff this filter will deliver true for any argument. Should
+	 * never be overridden except by classes generated by any() below.
+	 * 
+	 * No longer needed after Java 8: optimizations of this kind are now a compiler/JVM concern.
+	 */
+	@Deprecated
+	public boolean isAny() {
+		return false;
+	}
+
+	/**
+	 * A Filter that accepts everything it's offered.
+	 * 
+	 * @deprecated use Filter.any()
+	 */
+	@SuppressWarnings({ "unchecked", "rawtypes" })
+	// Knowingly suppressed - maximum backward compatibility.
+	@Deprecated
+	public static final Filter any = new Filter() {
+		@Override
+		public final boolean isAny() {
+			return true;
+		}
+
+		@Override
+		public final boolean accept(Object o) {
+			return true;
+		}
+
+		@Override
+		public Filter and(Filter other) {
+			return other;
+		}
+
+		@Override
+		public ExtendedIterator filterKeep(Iterator it) {
+			return WrappedIterator.create(it);
+		}
+	};
+
+	/**
+	 * Use Java 8's lambda syntax, e.g. x -> true.
+	 */
+	@Deprecated
+	public static <T> Filter<T> any() {
+		return new Filter<T>() {
+			@Override
+			public final boolean isAny() {
+				return true;
+			}
+
+			@Override
+			public final boolean accept(T o) {
+				return true;
+			}
+
+			@Override
+			public Filter<T> and(Filter<T> other) {
+				return other;
+			}
+
+			@Override
+			public ExtendedIterator<T> filterKeep(Iterator<T> it) {
+				return WrappedIterator.create(it);
+			}
+		};
+	}
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/b2a1953b/jena-core/src/main/java/org/apache/jena/util/iterator/FilterDropIterator.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/util/iterator/FilterDropIterator.java b/jena-core/src/main/java/org/apache/jena/util/iterator/FilterDropIterator.java
deleted file mode 100644
index 3c442a4..0000000
--- a/jena-core/src/main/java/org/apache/jena/util/iterator/FilterDropIterator.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jena.util.iterator;
-
-import java.util.Iterator;
-
-/**
-    A subclass of FiterIterator which discards the elements that pass the
-    filter.
- */
-public class FilterDropIterator<T> extends FilterIterator<T> implements Iterator<T>
-    {
-    public FilterDropIterator( Filter<T> f, Iterator<T> it )
-        { super( f, it ); }
-    
-    @Override protected boolean accept( T x )
-        { return !f.accept( x ); }
-    }

http://git-wip-us.apache.org/repos/asf/jena/blob/b2a1953b/jena-core/src/main/java/org/apache/jena/util/iterator/FilterIterator.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/util/iterator/FilterIterator.java b/jena-core/src/main/java/org/apache/jena/util/iterator/FilterIterator.java
index 6ae9042..c5ddb83 100644
--- a/jena-core/src/main/java/org/apache/jena/util/iterator/FilterIterator.java
+++ b/jena-core/src/main/java/org/apache/jena/util/iterator/FilterIterator.java
@@ -20,6 +20,7 @@ package org.apache.jena.util.iterator;
 
 import java.util.Iterator;
 import java.util.NoSuchElementException;
+import java.util.function.Predicate;
 
 /** 
      Creates a sub-Iterator by filtering. This class should not be used
@@ -28,7 +29,7 @@ import java.util.NoSuchElementException;
  */
 public class FilterIterator<T> extends WrappedIterator<T>
     {
-	protected final Filter<T> f;
+	protected final Predicate<T> f;
 	protected T current;
     protected boolean canRemove;
     protected boolean hasCurrent;
@@ -38,7 +39,7 @@ public class FilterIterator<T> extends WrappedIterator<T>
         @param fl An object is included if it is accepted by this Filter.
         @param e The base Iterator.
     */        
-	public FilterIterator( Filter<T> fl, Iterator<T> e ) 
+	public FilterIterator( Predicate<T> fl, Iterator<T> e ) 
         {
 		super( e );
 		f = fl;
@@ -52,18 +53,11 @@ public class FilterIterator<T> extends WrappedIterator<T>
 	@Override public boolean hasNext() 
         {
 	    while (!hasCurrent && super.hasNext())
-            hasCurrent = accept( current = super.next() );
+            hasCurrent = f.test( current = super.next() );
         canRemove = false;
         return hasCurrent;
         }
 
-    /**
-        Overridden in Drop/Keep as appropriate. Answer true if the object is
-        to be kept in the output, false if it is to be dropped.
-    */
-    protected boolean accept( T x )
-        { return f.accept( x ); }
-    
     /** 
          Remove the current member from the underlying iterator. Legal only
          after a .next() but before any subsequent .hasNext(), because that

http://git-wip-us.apache.org/repos/asf/jena/blob/b2a1953b/jena-core/src/main/java/org/apache/jena/util/iterator/FilterKeepIterator.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/util/iterator/FilterKeepIterator.java b/jena-core/src/main/java/org/apache/jena/util/iterator/FilterKeepIterator.java
deleted file mode 100644
index 10220d8..0000000
--- a/jena-core/src/main/java/org/apache/jena/util/iterator/FilterKeepIterator.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jena.util.iterator;
-
-import java.util.Iterator;
-
-/**
-    A subclass of FilterIterator which keeps the elements that pass the
-    test.
-*/
-public class FilterKeepIterator<T> extends FilterIterator<T> implements Iterator<T>
-    {
-    public FilterKeepIterator( Filter<T> f, Iterator<T> it )
-        { super( f, it ); }
-    
-    @Override protected boolean accept( T x )
-        { return f.accept( x ); }
-    }

http://git-wip-us.apache.org/repos/asf/jena/blob/b2a1953b/jena-core/src/main/java/org/apache/jena/util/iterator/LazyIterator.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/util/iterator/LazyIterator.java b/jena-core/src/main/java/org/apache/jena/util/iterator/LazyIterator.java
index 2411413..8a26180 100644
--- a/jena-core/src/main/java/org/apache/jena/util/iterator/LazyIterator.java
+++ b/jena-core/src/main/java/org/apache/jena/util/iterator/LazyIterator.java
@@ -19,6 +19,7 @@
 package org.apache.jena.util.iterator;
 
 import java.util.function.Function;
+import java.util.function.Predicate;
 
 /** An ExtendedIterator that is created lazily.
  * This is useful when constructing an iterator is expensive and 
@@ -64,13 +65,13 @@ abstract public class LazyIterator<T> implements ExtendedIterator<T> {
 	}
 
 	@Override
-    public ExtendedIterator<T> filterKeep(Filter<T> f) {
+    public ExtendedIterator<T> filterKeep(Predicate<T> f) {
 		lazy();
 		return it.filterKeep(f);
 	}
 
 	@Override
-    public ExtendedIterator<T> filterDrop(Filter<T> f) {
+    public ExtendedIterator<T> filterDrop(Predicate<T> f) {
 		lazy();
 		return it.filterDrop(f);
 	}

http://git-wip-us.apache.org/repos/asf/jena/blob/b2a1953b/jena-core/src/main/java/org/apache/jena/util/iterator/NiceIterator.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/util/iterator/NiceIterator.java b/jena-core/src/main/java/org/apache/jena/util/iterator/NiceIterator.java
index 6e0432f..5ebfee1 100644
--- a/jena-core/src/main/java/org/apache/jena/util/iterator/NiceIterator.java
+++ b/jena-core/src/main/java/org/apache/jena/util/iterator/NiceIterator.java
@@ -20,6 +20,7 @@ package org.apache.jena.util.iterator;
 
 import java.util.*;
 import java.util.function.Function;
+import java.util.function.Predicate;
 
 /**
     NiceIterator is the standard base class implementing ExtendedIterator. It provides
@@ -152,15 +153,15 @@ public class NiceIterator<T> implements ExtendedIterator<T>
         make a new iterator, which is our elements that pass the filter
     */
     @Override
-    public ExtendedIterator<T> filterKeep( Filter<T> f )
-        { return new FilterKeepIterator<>( f, this ); }
+    public FilterIterator<T> filterKeep( Predicate<T> f )
+        { return new FilterIterator<>( f, this ); }
 
     /**
         make a new iterator, which is our elements that do not pass the filter
     */        
     @Override
-    public ExtendedIterator<T> filterDrop( final Filter<T> f )
-        { return new FilterDropIterator<>( f, this ); }
+    public FilterIterator<T> filterDrop( final Predicate<T> f )
+        { return new FilterIterator<>( f.negate(), this ); }
    
     /**
         make a new iterator which is the elementwise _map1_ of the base iterator.

http://git-wip-us.apache.org/repos/asf/jena/blob/b2a1953b/jena-core/src/main/java/org/apache/jena/util/iterator/UniqueFilter.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/util/iterator/UniqueFilter.java b/jena-core/src/main/java/org/apache/jena/util/iterator/UniqueFilter.java
index 1e82306..bc3be53 100644
--- a/jena-core/src/main/java/org/apache/jena/util/iterator/UniqueFilter.java
+++ b/jena-core/src/main/java/org/apache/jena/util/iterator/UniqueFilter.java
@@ -20,17 +20,18 @@ package org.apache.jena.util.iterator;
 
 import java.util.HashSet;
 import java.util.Set;
+import java.util.function.Predicate;
 
 /**
  * A Filter that filters out duplicate values.  
  */
-public class UniqueFilter<T> extends Filter<T> {
+public class UniqueFilter<T> implements Predicate<T> {
 
     /** The set of objects already seen */
     protected Set<T> seen = new HashSet<>();
 
 	@Override
-	public boolean accept(T o) {
+	public boolean test(T o) {
 		boolean retval = !seen.contains(o);
 		if (retval)
 		{

http://git-wip-us.apache.org/repos/asf/jena/blob/b2a1953b/jena-core/src/test/java/org/apache/jena/graph/test/TestTripleField.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/graph/test/TestTripleField.java b/jena-core/src/test/java/org/apache/jena/graph/test/TestTripleField.java
index 80147ba..46d3b6d 100644
--- a/jena-core/src/test/java/org/apache/jena/graph/test/TestTripleField.java
+++ b/jena-core/src/test/java/org/apache/jena/graph/test/TestTripleField.java
@@ -54,32 +54,25 @@ public class TestTripleField extends GraphTestBase
     
     public void testFilterSubject()
         {
-        assertTrue( Field.fieldSubject.filterOn( node( "a" ) ).accept( triple( "a P b" ) ) );
-        assertFalse( Field.fieldSubject.filterOn( node( "x" ) ).accept( triple( "a P b" ) ) );
+        assertTrue( Field.fieldSubject.filterOn( node( "a" ) ).test( triple( "a P b" ) ) );
+        assertFalse( Field.fieldSubject.filterOn( node( "x" ) ).test( triple( "a P b" ) ) );
         }    
     
     public void testFilterObject()
         {
-        assertTrue( Field.fieldObject.filterOn( node( "b" ) ).accept( triple( "a P b" ) ) );
-        assertFalse( Field.fieldObject.filterOn( node( "c" ) ).accept( triple( "a P b" ) ) );
+        assertTrue( Field.fieldObject.filterOn( node( "b" ) ).test( triple( "a P b" ) ) );
+        assertFalse( Field.fieldObject.filterOn( node( "c" ) ).test( triple( "a P b" ) ) );
         }
     
     public void testFilterPredicate()
         {
-        assertTrue( Field.fieldPredicate.filterOn( node( "P" ) ).accept( triple( "a P b" ) ) );
-        assertFalse( Field.fieldPredicate.filterOn( node( "Q" ) ).accept( triple( "a P b" ) ) );
+        assertTrue( Field.fieldPredicate.filterOn( node( "P" ) ).test( triple( "a P b" ) ) );
+        assertFalse( Field.fieldPredicate.filterOn( node( "Q" ) ).test( triple( "a P b" ) ) );
         }
     
     public void testFilterByTriple()
         {
-        assertTrue( Field.fieldSubject.filterOn( triple( "s P o" ) ).accept( triple( "s Q p" ) ) );
-        assertFalse( Field.fieldSubject.filterOn( triple( "s P o" ) ).accept( triple( "x Q p" ) ) );
-        }
-    
-    public void testWildcardFilterIsAny()
-        {
-        assertTrue( Field.fieldSubject.filterOn( triple( "?x R s" ) ).isAny() );
-        assertTrue( Field.fieldObject.filterOn( triple( "x R ?s" ) ).isAny() );
-        assertTrue( Field.fieldPredicate.filterOn( triple( "x ?R s" ) ).isAny() );
+        assertTrue( Field.fieldSubject.filterOn( triple( "s P o" ) ).test( triple( "s Q p" ) ) );
+        assertFalse( Field.fieldSubject.filterOn( triple( "s P o" ) ).test( triple( "x Q p" ) ) );
         }
     }

http://git-wip-us.apache.org/repos/asf/jena/blob/b2a1953b/jena-core/src/test/java/org/apache/jena/ontology/impl/TestOntTools.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/ontology/impl/TestOntTools.java b/jena-core/src/test/java/org/apache/jena/ontology/impl/TestOntTools.java
index 7bef377..f57a48d 100644
--- a/jena-core/src/test/java/org/apache/jena/ontology/impl/TestOntTools.java
+++ b/jena-core/src/test/java/org/apache/jena/ontology/impl/TestOntTools.java
@@ -24,8 +24,10 @@ package org.apache.jena.ontology.impl;
 // Imports
 ///////////////
 import java.util.List ;
+import java.util.function.Predicate;
 
 import junit.framework.TestCase ;
+
 import org.apache.jena.ontology.OntClass ;
 import org.apache.jena.ontology.OntModel ;
 import org.apache.jena.ontology.OntModelSpec ;
@@ -34,7 +36,6 @@ import org.apache.jena.rdf.model.ModelFactory ;
 import org.apache.jena.rdf.model.Property ;
 import org.apache.jena.rdf.model.ResourceFactory ;
 import org.apache.jena.rdf.model.Statement ;
-import org.apache.jena.util.iterator.Filter ;
 import org.apache.jena.vocabulary.OWL ;
 
 
@@ -227,7 +228,7 @@ public class TestOntTools
 
     /** Shortest path tests */
 
-    static final Filter<Statement> ANY = Filter.any();
+    static final Predicate<Statement> ANY = s -> true;
 
     public void testShortestPath0() {
         Property p = m_model.createProperty( NS + "p" );

http://git-wip-us.apache.org/repos/asf/jena/blob/b2a1953b/jena-core/src/test/java/org/apache/jena/util/iterator/test/TestFilters.java
----------------------------------------------------------------------
diff --git a/jena-core/src/test/java/org/apache/jena/util/iterator/test/TestFilters.java b/jena-core/src/test/java/org/apache/jena/util/iterator/test/TestFilters.java
index ac984c5..66e589c 100644
--- a/jena-core/src/test/java/org/apache/jena/util/iterator/test/TestFilters.java
+++ b/jena-core/src/test/java/org/apache/jena/util/iterator/test/TestFilters.java
@@ -19,10 +19,11 @@
 package org.apache.jena.util.iterator.test;
 
 import java.util.*;
+import java.util.function.Predicate;
 
 import junit.framework.TestSuite;
+
 import org.apache.jena.rdf.model.test.ModelTestBase ;
-import org.apache.jena.shared.JenaException ;
 import org.apache.jena.util.iterator.* ;
 
 public class TestFilters extends ModelTestBase
@@ -32,86 +33,13 @@ public class TestFilters extends ModelTestBase
     
     public static TestSuite suite()
         { return new TestSuite( TestFilters.class ); }
-    
-    public void testFilterAnyExists()
-        { assertInstanceOf( Filter.class, Filter.any() ); }
-    
-    public void testFilterAnyAcceptsThings()
-        {
-        assertTrue( Filter.any().accept( "hello" ) );
-        assertTrue( Filter.any().accept( 17 ) );
-        assertTrue( Filter.any().accept( node( "frodo" ) ) );
-        assertTrue( Filter.any().accept( node( "_cheshire" ) ) );
-        assertTrue( Filter.any().accept( node( "17" ) ) );
-        assertTrue( Filter.any().accept( triple( "s p o" ) ) );
-        assertTrue( Filter.any().accept( Filter.any() ) );
-        assertTrue( Filter.any().accept( this ) );
-        }
-    
-    public void testFilterFilterMethod()
-        {
-        assertFalse( Filter.any().filterKeep( NullIterator.instance() ).hasNext() );
-        }
-    
-    public void testFilteringThings()
-        {
-        ExtendedIterator<String> it = iteratorOfStrings( "gab geb bag big lava hall end" );
-        Filter<String> f = new Filter<String>() 
-            {
-            @Override public boolean accept( String o )
-                { return o.charAt( 1 ) == 'a'; }
-            };
-        assertEquals( listOfStrings( "gab bag lava hall" ), iteratorToList( f.filterKeep( it ) ) );
-        }
-    
-    public void testAnyFilterSimple()
-        {
-        ExtendedIterator<String> it = iteratorOfStrings( "" );
-        assertSame( it, Filter.<String>any().filterKeep( it ) );
-        }
 
-    protected Filter<String> containsA = new Filter<String>() 
-        { @Override public boolean accept( String o ) { return contains( o, 'a' ); } };
-    
-    public void testFilterAnd()
-        {
-        Filter<String> containsB = new Filter<String>() 
-            { @Override public boolean accept( String o ) { return contains( o, 'b' ); } };
-        Filter<String> f12 = containsA.and( containsB );
-        assertFalse( f12.accept( "a" ) );
-        assertFalse( f12.accept( "b" ) );
-        assertTrue( f12.accept( "ab" ) );
-        assertTrue( f12.accept( "xyzapqrbijk" ) );
-        assertTrue( f12.accept( "ba" ) );
-        }
-    
-    public void testFilterShortcircuit()
-        {
-        Filter<String> oops = new Filter<String>() 
-            { @Override public boolean accept( String o ) { throw new JenaException( "oops" ); } };
-        Filter<String> f12 = containsA.and( oops );
-        assertFalse( f12.accept( "z" ) );
-        try { f12.accept( "a" ); fail( "oops" ); }
-        catch (JenaException e) { assertEquals( "oops", e.getMessage() ); }
-        }
-    
-    public void testAnyAndTrivial()
-        { assertSame( containsA, Filter.<String>any().and( containsA ) ); }
-    
-    public void testSomethingAndAny()
-        { assertSame( containsA, containsA.and( Filter.<String>any() ) ); }
-    
-    public void testFilterDropIterator()
-        {
-        Iterator<String> i = iteratorOfStrings( "there's an a in some animals" );
-        Iterator<String> it = new FilterDropIterator<>( containsA, i );
-        assertEquals( listOfStrings( "there's in some" ), iteratorToList( it ) );
-        }
+    protected Predicate<String> containsA = o -> contains( o, 'a' );    
     
-    public void testFilterKeepIterator()
+    public void testFilterIterator()
         {
         Iterator<String> i = iteratorOfStrings( "there's an a in some animals" );
-        Iterator<String> it = new FilterKeepIterator<>( containsA, i );
+        Iterator<String> it = new FilterIterator<>( containsA, i );
         assertEquals( listOfStrings( "an a animals" ), iteratorToList( it ) );
         }
     

http://git-wip-us.apache.org/repos/asf/jena/blob/b2a1953b/jena-csv/src/main/java/org/apache/jena/propertytable/graph/GraphPropertyTable.java
----------------------------------------------------------------------
diff --git a/jena-csv/src/main/java/org/apache/jena/propertytable/graph/GraphPropertyTable.java b/jena-csv/src/main/java/org/apache/jena/propertytable/graph/GraphPropertyTable.java
index 3a5b2af..7e5e5b5 100644
--- a/jena-csv/src/main/java/org/apache/jena/propertytable/graph/GraphPropertyTable.java
+++ b/jena-csv/src/main/java/org/apache/jena/propertytable/graph/GraphPropertyTable.java
@@ -20,6 +20,7 @@ package org.apache.jena.propertytable.graph;
 
 import java.util.ArrayList ;
 import java.util.Locale ;
+import java.util.function.Predicate;
 
 import org.apache.jena.graph.Node ;
 import org.apache.jena.graph.NodeFactory ;
@@ -30,7 +31,6 @@ import org.apache.jena.propertytable.PropertyTable ;
 import org.apache.jena.propertytable.Row ;
 import org.apache.jena.sparql.core.BasicPattern ;
 import org.apache.jena.util.iterator.ExtendedIterator ;
-import org.apache.jena.util.iterator.Filter ;
 import org.apache.jena.util.iterator.NullIterator ;
 import org.apache.jena.util.iterator.WrappedIterator ;
 
@@ -117,7 +117,7 @@ public class GraphPropertyTable extends GraphBase {
 		
 	}
 	
-	static class RowMatchFilterEquality extends Filter<Row> {
+	static class RowMatchFilterEquality implements Predicate<Row> {
 		final protected RowMatch rMatch;
 
 		public RowMatchFilterEquality(RowMatch rMatch) {
@@ -125,7 +125,7 @@ public class GraphPropertyTable extends GraphBase {
 		}
 
 		@Override
-		public boolean accept(Row r) {
+		public boolean test(Row r) {
 			return rowContained(rMatch, r);
 		}
 
@@ -147,7 +147,7 @@ public class GraphPropertyTable extends GraphBase {
 	}
 	
 
-	static class TripleMatchFilterEquality extends Filter<Triple> {
+	static class TripleMatchFilterEquality implements Predicate<Triple> {
 		final protected Triple tMatch;
 
 		/** Creates new TripleMatchFilter */
@@ -156,7 +156,7 @@ public class GraphPropertyTable extends GraphBase {
 		}
 
 		@Override
-		public boolean accept(Triple t) {
+		public boolean test(Triple t) {
 			return tripleContained(tMatch, t);
 		}
 

http://git-wip-us.apache.org/repos/asf/jena/blob/b2a1953b/jena-permissions/src/main/java/org/apache/jena/permissions/model/impl/SecuredModelImpl.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/main/java/org/apache/jena/permissions/model/impl/SecuredModelImpl.java b/jena-permissions/src/main/java/org/apache/jena/permissions/model/impl/SecuredModelImpl.java
index 072396f..37d856b 100644
--- a/jena-permissions/src/main/java/org/apache/jena/permissions/model/impl/SecuredModelImpl.java
+++ b/jena-permissions/src/main/java/org/apache/jena/permissions/model/impl/SecuredModelImpl.java
@@ -20,6 +20,7 @@ package org.apache.jena.permissions.model.impl;
 import java.io.* ;
 import java.net.URL ;
 import java.util.* ;
+import java.util.function.Predicate;
 
 import org.apache.jena.datatypes.RDFDatatype ;
 import org.apache.jena.graph.Node ;
@@ -40,7 +41,6 @@ import org.apache.jena.rdf.model.* ;
 import org.apache.jena.rdf.model.impl.RDFReaderFImpl ;
 import org.apache.jena.shared.* ;
 import org.apache.jena.util.iterator.ExtendedIterator ;
-import org.apache.jena.util.iterator.Filter ;
 import org.apache.jena.util.iterator.WrappedIterator ;
 import org.apache.jena.vocabulary.RDF ;
 
@@ -265,7 +265,7 @@ public class SecuredModelImpl extends SecuredItemImpl implements SecuredModel
 			this.p = p;
 		}
 		@Override
-		public boolean accept(Resource o) {
+		public boolean test(Resource o) {
 			Triple t = new Triple( r.asNode(), p.asNode(), o.asNode());
 			return si.canRead( SecuredItemImpl.convert( t ) );
 		}};
@@ -2673,7 +2673,7 @@ public class SecuredModelImpl extends SecuredItemImpl implements SecuredModel
 
 	}
 	
-	private class ResourceFilter extends Filter<Resource> {
+	private class ResourceFilter implements Predicate<Resource> {
 		Property p;
 		RDFNode o;
 		
@@ -2693,7 +2693,7 @@ public class SecuredModelImpl extends SecuredItemImpl implements SecuredModel
 		}
 		
 		@Override
-		public boolean accept(Resource s) {
+		public boolean test(Resource s) {
 			StmtIterator iter = listStatements(s, p, o);
 			try {
 				return iter.hasNext();
@@ -2705,7 +2705,7 @@ public class SecuredModelImpl extends SecuredItemImpl implements SecuredModel
 		
 	}
 	
-	private class ObjectFilter extends Filter<RDFNode> {
+	private class ObjectFilter implements Predicate<RDFNode> {
 		Resource s;
 		Property p;
 
@@ -2725,7 +2725,7 @@ public class SecuredModelImpl extends SecuredItemImpl implements SecuredModel
 		}
 		
 		@Override
-		public boolean accept(RDFNode o) {
+		public boolean test(RDFNode o) {
 			StmtIterator iter = listStatements(s, p, o);
 			try {
 				return iter.hasNext();

http://git-wip-us.apache.org/repos/asf/jena/blob/b2a1953b/jena-permissions/src/main/java/org/apache/jena/permissions/model/impl/SecuredNodeIterator.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/main/java/org/apache/jena/permissions/model/impl/SecuredNodeIterator.java b/jena-permissions/src/main/java/org/apache/jena/permissions/model/impl/SecuredNodeIterator.java
index 558f184..c9df0ba 100644
--- a/jena-permissions/src/main/java/org/apache/jena/permissions/model/impl/SecuredNodeIterator.java
+++ b/jena-permissions/src/main/java/org/apache/jena/permissions/model/impl/SecuredNodeIterator.java
@@ -22,13 +22,13 @@ import java.util.List;
 import java.util.NoSuchElementException;
 import java.util.Set;
 import java.util.function.Function;
+import java.util.function.Predicate;
 
 import org.apache.jena.permissions.model.SecuredModel;
 import org.apache.jena.permissions.model.SecuredRDFNode;
 import org.apache.jena.rdf.model.NodeIterator ;
 import org.apache.jena.rdf.model.RDFNode ;
 import org.apache.jena.util.iterator.ExtendedIterator ;
-import org.apache.jena.util.iterator.Filter ;
 
 /**
  * A secured RDFNode iterator implementation
@@ -82,13 +82,13 @@ public class SecuredNodeIterator<T extends RDFNode> implements NodeIterator
 	}
 
 	@Override
-	public ExtendedIterator<RDFNode> filterDrop( final Filter<RDFNode> f )
+	public ExtendedIterator<RDFNode> filterDrop( final Predicate<RDFNode> f )
 	{
 		return iter.filterDrop(f);
 	}
 
 	@Override
-	public ExtendedIterator<RDFNode> filterKeep( final Filter<RDFNode> f )
+	public ExtendedIterator<RDFNode> filterKeep( final Predicate<RDFNode> f )
 	{
 		return iter.filterKeep(f);
 	}

http://git-wip-us.apache.org/repos/asf/jena/blob/b2a1953b/jena-permissions/src/main/java/org/apache/jena/permissions/model/impl/SecuredRSIterator.java
----------------------------------------------------------------------
diff --git a/jena-permissions/src/main/java/org/apache/jena/permissions/model/impl/SecuredRSIterator.java b/jena-permissions/src/main/java/org/apache/jena/permissions/model/impl/SecuredRSIterator.java
index 2160880..2fbbb40 100644
--- a/jena-permissions/src/main/java/org/apache/jena/permissions/model/impl/SecuredRSIterator.java
+++ b/jena-permissions/src/main/java/org/apache/jena/permissions/model/impl/SecuredRSIterator.java
@@ -21,6 +21,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
 import java.util.function.Function;
+import java.util.function.Predicate;
 
 import org.apache.jena.permissions.SecurityEvaluator;
 import org.apache.jena.permissions.SecurityEvaluator.Action;
@@ -30,14 +31,13 @@ import org.apache.jena.permissions.model.SecuredModel;
 import org.apache.jena.rdf.model.RSIterator ;
 import org.apache.jena.rdf.model.ReifiedStatement ;
 import org.apache.jena.util.iterator.ExtendedIterator ;
-import org.apache.jena.util.iterator.Filter ;
 
 /**
  * A secured RSIterator implementation
  */
 public class SecuredRSIterator implements RSIterator
 {
-	private class PermReifiedStatementFilter extends Filter<ReifiedStatement>
+	private class PermReifiedStatementFilter implements Predicate<ReifiedStatement>
 	{
 		private final SecurityEvaluator evaluator;
 		private final SecNode modelNode;
@@ -52,7 +52,7 @@ public class SecuredRSIterator implements RSIterator
 		}
 
 		@Override
-		public boolean accept( final ReifiedStatement t )
+		public boolean test( final ReifiedStatement t )
 		{
 			return evaluator.evaluateAny(evaluator.getPrincipal(), actions, modelNode,
 					SecuredItemImpl.convert(t.getStatement().asTriple()));
@@ -111,14 +111,14 @@ public class SecuredRSIterator implements RSIterator
 
 	@Override
 	public ExtendedIterator<ReifiedStatement> filterDrop(
-			final Filter<ReifiedStatement> f )
+			final Predicate<ReifiedStatement> f )
 	{
 		return iter.filterDrop(f);
 	}
 
 	@Override
 	public ExtendedIterator<ReifiedStatement> filterKeep(
-			final Filter<ReifiedStatement> f )
+			final Predicate<ReifiedStatement> f )
 	{
 		return iter.filterKeep(f);
 	}


Mime
View raw message