WhereHandler implements Handler { public void addMinus( AbstractQueryBuilder<?> qb ) { PrologHandler ph = new PrologHandler(query); ph.addPrefixes( qb.getPrologHandler().getPrefixes() ); ElementGroup clause = getClause(); ElementMinus minus = new ElementMinus(qb.getWhereHandler().getClause()); clause.addElement(minus); } WhereHandler(Query query);  WhereHandler(); Element getQueryPattern(); Query getQuery(); void addAll(WhereHandler whereHandler); Element getElement(); ElementGroup getClause(); void addWhere(TriplePath t); void addWhere(ValuesHandler values); void addOptional(TriplePath t); void addOptional(WhereHandler whereHandler); void addFilter(String expression); void addFilter(Expr expr); void addSubQuery(AbstractQueryBuilder<?> subQuery); ElementSubQuery makeSubQuery(AbstractQueryBuilder<?> subQuery); void addUnion(AbstractQueryBuilder<?> subQuery); void addGraph(Node graph, WhereHandler subQuery); void addGraph(Node graph, TriplePath subQuery); void addBind(Expr expr, Var var); void addBind(String expression, Var var); @Override void setVars(Map<Var, Node> values); @Override void build(); Node list(Object... objs); void addMinus( AbstractQueryBuilder<?> qb ); void addValueVar(PrefixMapping prefixMapping, Object var); void addValueVar(PrefixMapping prefixMapping, Object var, Object... objects); void addValueVars(PrefixMapping prefixMapping, Map<?,K> dataTable); void addValueRow(PrefixMapping prefixMapping, Object... values); void addValueRow(PrefixMapping prefixMapping, Collection<?> values); List<Var> getValuesVars(); Map<Var,List<Node>> getValuesMap(); void clearValues();  }
@Test public void testAddMinus() { SelectBuilder sb = new SelectBuilder(); sb.addPrefix("pfx", "uri").addWhere("<one>", "<two>", "three"); handler.addMinus(sb); handler.build(); ElementPathBlock epb = new ElementPathBlock(); ElementMinus minus = new ElementMinus(epb); epb.addTriplePath( new TriplePath( new Triple( NodeFactory.createURI("one"), NodeFactory.createURI("two"), NodeFactory.createLiteral("three")))); WhereValidator visitor = new WhereValidator( minus ); query.getQueryPattern().visit( visitor ); assertTrue( visitor.matching ); }