Variable x = new Variable("x");
Set<TriplePattern> triplePatterns = new HashSet<TriplePattern>();
triplePatterns.add(new SimpleTriplePattern(x,
new UriRef("http://purl.org/dc/elements/1.1/title"), title));
SimpleBasicGraphPattern bgp = new SimpleBasicGraphPattern(triplePatterns);
Set<TriplePattern> triplePatternsOpt = new HashSet<TriplePattern>();
triplePatternsOpt.add(new SimpleTriplePattern(x,
new UriRef("http://example.org/ns#price"), price));
SimpleBasicGraphPattern bgpOpt =
new SimpleBasicGraphPattern(triplePatternsOpt);
SimpleGroupGraphPattern ggpOpt = new SimpleGroupGraphPattern();
ggpOpt.addGraphPattern(bgpOpt);
SimpleOptionalGraphPattern ogp = new SimpleOptionalGraphPattern(bgp, ggpOpt);