@Test public void findProjection_distinctIsTopNode() throws MalformedQueryException { String sparql = "SELECT DISTINCT ?a ?b " + "WHERE {" + "?a <http: "}"; SPARQLParser parser = new SPARQLParser(); ParsedQuery query = parser.parseQuery(sparql, null); Optional<Projection> projection = new ParsedQueryUtil().findProjection(query); assertTrue(projection.isPresent()); }
public Optional<Projection> findProjection(final ParsedQuery query) { checkNotNull(query); final AtomicReference<Projection> projectionRef = new AtomicReference<>(); query.getTupleExpr().visit(new AbstractQueryModelVisitor<RuntimeException>() { @Override public void meet(Projection projection) { projectionRef.set(projection); } }); return Optional.fromNullable( projectionRef.get() ); }
ParsedQueryUtil { public Optional<Projection> findProjection(final ParsedQuery query) { checkNotNull(query); final AtomicReference<Projection> projectionRef = new AtomicReference<>(); query.getTupleExpr().visit(new AbstractQueryModelVisitor<RuntimeException>() { @Override public void meet(Projection projection) { projectionRef.set(projection); } }); return Optional.fromNullable( projectionRef.get() ); } }
ParsedQueryUtil { public Optional<Projection> findProjection(final ParsedQuery query) { checkNotNull(query); final AtomicReference<Projection> projectionRef = new AtomicReference<>(); query.getTupleExpr().visit(new AbstractQueryModelVisitor<RuntimeException>() { @Override public void meet(Projection projection) { projectionRef.set(projection); } }); return Optional.fromNullable( projectionRef.get() ); }  }
ParsedQueryUtil { public Optional<Projection> findProjection(final ParsedQuery query) { checkNotNull(query); final AtomicReference<Projection> projectionRef = new AtomicReference<>(); query.getTupleExpr().visit(new AbstractQueryModelVisitor<RuntimeException>() { @Override public void meet(Projection projection) { projectionRef.set(projection); } }); return Optional.fromNullable( projectionRef.get() ); }  Optional<Projection> findProjection(final ParsedQuery query); }
ParsedQueryUtil { public Optional<Projection> findProjection(final ParsedQuery query) { checkNotNull(query); final AtomicReference<Projection> projectionRef = new AtomicReference<>(); query.getTupleExpr().visit(new AbstractQueryModelVisitor<RuntimeException>() { @Override public void meet(Projection projection) { projectionRef.set(projection); } }); return Optional.fromNullable( projectionRef.get() ); }  Optional<Projection> findProjection(final ParsedQuery query);  }