Diagram { public static Figure text( String text ) { return FigureBuilder.text( text ); } private  Diagram( String name, Figure root ); static List<Diagram> build( Grammar grammar, BuilderOptions options ); static Diagram build( Production production, BuilderOptions options ); void render( R renderer ); void render( Renderer<Canvas, ?, EX> renderer, CanvasProvider<? extends Canvas, ? extends EX> provider ); Result convert( R renderer ); Result convert( Renderer<? super Canvas, ?, EX> renderer, P provider ); Result convert( R renderer,
                                                                            Function<Canvas, Result> finish ); Result convert(
            Renderer<? super Canvas, ?, EX> renderer,
            CanvasProvider<? extends Canvas, ? extends EX> provider,
            Function<Canvas, Result> finish ); String name(); @Override boolean equals( Object o ); @Override int hashCode(); @Override String toString(); static Diagram diagram( String name, Figure figure ); static Figure nothing(); static Figure text( String text ); static Figure anyCase( String text ); static Figure reference( String name ); static Figure charset( String set ); static Figure line( Diagram.Figure... content ); static Figure branch( Diagram.Figure... branches ); static Figure loop( Diagram.Figure forward, Diagram.Figure backwards, int minTimes, Integer maxTimes );  }
@Test public static Expectation shouldText() throws Exception { return givenProduction( "foo", literal( "FOO" ) ) .expectDiagram( "foo", text( "FOO" ) ); }
@Test public static Expectation shouldEliminateRedundantNothing() throws Exception { return givenProduction( "bar", sequence( sequence( oneOf( sequence( literal( "BAR" ), epsilon() ) ), oneOf( epsilon(), epsilon() ) ) ) ) .expectDiagram( "bar", text( "BAR" ) ); }