You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2016/08/27 20:50:50 UTC
[3/3] jena git commit: Comments and deprecation for Opfilter.filter
Comments and deprecation for Opfilter.filter
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/dabdb533
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/dabdb533
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/dabdb533
Branch: refs/heads/master
Commit: dabdb5334648b022f70a19f3d67d720458e05a39
Parents: 3f5e15a
Author: Andy Seaborne <an...@apache.org>
Authored: Sat Aug 27 21:50:31 2016 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Sat Aug 27 21:50:31 2016 +0100
----------------------------------------------------------------------
.../apache/jena/sparql/algebra/op/OpFilter.java | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/dabdb533/jena-arq/src/main/java/org/apache/jena/sparql/algebra/op/OpFilter.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/algebra/op/OpFilter.java b/jena-arq/src/main/java/org/apache/jena/sparql/algebra/op/OpFilter.java
index 83b384d..4b01b8a 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/algebra/op/OpFilter.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/algebra/op/OpFilter.java
@@ -32,16 +32,20 @@ public class OpFilter extends Op1
/** Add expression - mutates an existing filter */
public static Op filter(Expr expr, Op op) {
- OpFilter f = filter(op) ;
+ OpFilter f = ensureFilter(op) ;
f.getExprs().add(expr) ;
return f ;
}
/**
* Ensure that the algebra op is a filter. If the input is a filter, just return that,
- * else create a filter with no expressions and this as the subOp
+ * else create a filter with no expressions and "this" as the subOp.
+ * @apiNote
+ * This operation assumes the caller is going to add expressions.
+ * Filters without any expressions are discouraged.
+ * Consider collecting the expressions together first and using {@link #filterBy}.
*/
- public static OpFilter filter(Op op) {
+ public static OpFilter ensureFilter(Op op) {
if ( op instanceof OpFilter )
return (OpFilter)op ;
else
@@ -54,6 +58,10 @@ public class OpFilter extends Op1
return filterBy(exprs, op) ;
}
+ /** @deprecated Use {@link #ensureFilter} */
+ @Deprecated
+ public static OpFilter filter(Op op) { return ensureFilter(op) ; }
+
/** Combine an ExprList with an Op so that the expressions filter the Op.
* If the exprs are empty, return the Op.
* If the op is already a OpFilter, merge the expressions into the filters existintg expressions.
@@ -62,7 +70,7 @@ public class OpFilter extends Op1
public static Op filterBy(ExprList exprs, Op op) {
if ( exprs == null || exprs.isEmpty() )
return op ;
- OpFilter f = filter(op) ;
+ OpFilter f = ensureFilter(op) ;
f.getExprs().addAll(exprs) ;
return f ;
}
@@ -71,7 +79,7 @@ public class OpFilter extends Op1
* If subOp is a filter, combine expressions (de-layer).
*/
public static OpFilter filterAlways(ExprList exprs, Op subOp) {
- OpFilter f = filter(subOp) ;
+ OpFilter f = ensureFilter(subOp) ;
f.getExprs().addAll(exprs) ;
return f ;
}