### Question:
OptionalBlock implements ContainerBlock { @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append("OPTIONAL { "); for (Block block : blocks) { builder.append(block.toString()).append(" "); } if (filters != null) { builder.append(" FILTER(").append(filters).append(")"); } builder.append(" }"); return builder.toString(); } OptionalBlock(List<Block> blocks, Predicate... filters); @Override Predicate not(); @SuppressWarnings("unchecked") @Override R accept(Visitor<R, C> v, C context); @Override Class<? extends Boolean> getType(); List<Block> getBlocks(); @Nullable Predicate getFilters(); @Override BooleanExpression exists(); @Override int hashCode(); @Override boolean equals(Object o); @Override String toString();  }### Answer:
@Test public void To_String() { Block block = Blocks.optional(Blocks.SPOC); assertEquals("OPTIONAL { {s} {p} {o} {c} . }", block.toString()); }
@Test public void To_String_with_Filter() { Block block = Blocks.optionalFilter(Blocks.SPOC, QNODE.o.lit().lt("X")); assertEquals("OPTIONAL { {s} {p} {o} {c} . FILTER({o} < \"X\") }", block.toString()); }