TupleExprs { public static boolean isFilterExistsFunction(TupleExpr expr) { if (expr instanceof Filter) { Filter filter = (Filter) expr; if (filter.getCondition() instanceof Exists) { return true; } else if (filter.getCondition() instanceof Not) { Not n = (Not) filter.getCondition(); return (n.getArg() instanceof Exists); } } return false; }  static boolean containsSubquery(TupleExpr t); static boolean isVariableScopeChange(TupleExpr expr); @Deprecated static boolean isGraphPatternGroup(TupleExpr expr); @Deprecated static boolean containsProjection(TupleExpr t); static List<TupleExpr> getChildren(TupleExpr t); static Var createConstVar(Value value); static String getConstVarName(Value value); static boolean isFilterExistsFunction(TupleExpr expr);  }
@Test public void isFilterExistsFunctionOnEmptyFilter() { TupleExpr expr = new Filter(); assertThat(isFilterExistsFunction(expr)).isFalse(); }
@Test public void isFilterExistsFunctionOnNormalFilter() { Filter expr = new Filter(); expr.setArg(new StatementPattern()); expr.setCondition(new Compare(new Var("x", f.createBNode()), new Var("y", f.createBNode()))); assertThat(isFilterExistsFunction(expr)).isFalse(); }
@Test public void isFilterExistsFunctionOnNormalNot() { Filter expr = new Filter(); expr.setArg(new StatementPattern()); expr.setCondition(new Not(new Compare(new Var("x", f.createBNode()), new Var("y", f.createBNode())))); assertThat(isFilterExistsFunction(expr)).isFalse(); }
@Test public void isFilterExistsFunctionOnExists() { Filter expr = new Filter(); expr.setArg(new StatementPattern()); expr.setCondition(new Exists(new StatementPattern())); assertThat(isFilterExistsFunction(expr)).isTrue(); }
@Test public void isFilterExistsFunctionOnNotExist() { Filter expr = new Filter(); expr.setArg(new StatementPattern()); expr.setCondition(new Not(new Exists(new StatementPattern()))); assertThat(isFilterExistsFunction(expr)).isTrue(); }