@Test public void testOptionalInOptionalTreeBuildup() throws Exception { var f = FluentBuilder.from(TestClass.class); var aOrB = f.oneOf(f.optional("a"), f.one("b")); var fluent = f.one("a") .optional(aOrB) .one("c").cloner("copy"); var result = new ClassBuilder((FluentBuilderImpl) fluent).build(); assertEqualToFile(result, "testOptionalInOptionalTreeBuildup.txt"); }
public String build() throws Exception { LOG.debug("Class building started for the class %s", fluent.getKlass().getSimpleName()); var list = fluent.getNodes(); if (list.size() == 0) { throw new GeciException("There are no actual calls in the fluent structure."); } LOG.debug("There are %d nodes on the top level", list.size()); final var tree = new Tree(Node.ONCE, list); final var exitType = NodeTypeCalculator.from(methods).getReturnType(getLastNode(list)); final var lastInterface = GeciReflectionTools.normalizeTypeName(exitType); LOG.debug("The last type is %s", lastInterface); final var interfaces = build(tree, lastInterface); final var code = JavaSource.builder(); writeStartMethod(code); writeWrapperInterface(code); writeWrapperClass(code); code.write(interfaces); return code.toString(); }
ClassBuilder { public String build() throws Exception { LOG.debug("Class building started for the class %s", fluent.getKlass().getSimpleName()); var list = fluent.getNodes(); if (list.size() == 0) { throw new GeciException("There are no actual calls in the fluent structure."); } LOG.debug("There are %d nodes on the top level", list.size()); final var tree = new Tree(Node.ONCE, list); final var exitType = NodeTypeCalculator.from(methods).getReturnType(getLastNode(list)); final var lastInterface = GeciReflectionTools.normalizeTypeName(exitType); LOG.debug("The last type is %s", lastInterface); final var interfaces = build(tree, lastInterface); final var code = JavaSource.builder(); writeStartMethod(code); writeWrapperInterface(code); writeWrapperClass(code); code.write(interfaces); return code.toString(); } }
ClassBuilder { public String build() throws Exception { LOG.debug("Class building started for the class %s", fluent.getKlass().getSimpleName()); var list = fluent.getNodes(); if (list.size() == 0) { throw new GeciException("There are no actual calls in the fluent structure."); } LOG.debug("There are %d nodes on the top level", list.size()); final var tree = new Tree(Node.ONCE, list); final var exitType = NodeTypeCalculator.from(methods).getReturnType(getLastNode(list)); final var lastInterface = GeciReflectionTools.normalizeTypeName(exitType); LOG.debug("The last type is %s", lastInterface); final var interfaces = build(tree, lastInterface); final var code = JavaSource.builder(); writeStartMethod(code); writeWrapperInterface(code); writeWrapperClass(code); code.write(interfaces); return code.toString(); } ClassBuilder(FluentBuilderImpl fluent); private  ClassBuilder(ClassBuilder that); }
ClassBuilder { public String build() throws Exception { LOG.debug("Class building started for the class %s", fluent.getKlass().getSimpleName()); var list = fluent.getNodes(); if (list.size() == 0) { throw new GeciException("There are no actual calls in the fluent structure."); } LOG.debug("There are %d nodes on the top level", list.size()); final var tree = new Tree(Node.ONCE, list); final var exitType = NodeTypeCalculator.from(methods).getReturnType(getLastNode(list)); final var lastInterface = GeciReflectionTools.normalizeTypeName(exitType); LOG.debug("The last type is %s", lastInterface); final var interfaces = build(tree, lastInterface); final var code = JavaSource.builder(); writeStartMethod(code); writeWrapperInterface(code); writeWrapperClass(code); code.write(interfaces); return code.toString(); } ClassBuilder(FluentBuilderImpl fluent); private  ClassBuilder(ClassBuilder that); String build(); }
ClassBuilder { public String build() throws Exception { LOG.debug("Class building started for the class %s", fluent.getKlass().getSimpleName()); var list = fluent.getNodes(); if (list.size() == 0) { throw new GeciException("There are no actual calls in the fluent structure."); } LOG.debug("There are %d nodes on the top level", list.size()); final var tree = new Tree(Node.ONCE, list); final var exitType = NodeTypeCalculator.from(methods).getReturnType(getLastNode(list)); final var lastInterface = GeciReflectionTools.normalizeTypeName(exitType); LOG.debug("The last type is %s", lastInterface); final var interfaces = build(tree, lastInterface); final var code = JavaSource.builder(); writeStartMethod(code); writeWrapperInterface(code); writeWrapperClass(code); code.write(interfaces); return code.toString(); } ClassBuilder(FluentBuilderImpl fluent); private  ClassBuilder(ClassBuilder that); String build();  }