Creating nested fluent API in Java <p>We are trying to come up with fluent API for nested Object. Consider we have following three classes</p> <p>Attribute : name : String Value : Object</p> <p>Item : action : String attributes : </p> <p>Order : action : String attributes : items : </p> <p>Here we want to have fluent API which can help to build above Objects.</p> <p>Now we need to have builders as follows:</p> <h3>Attribute Builder</h3> <pre><code>AttributeBuilder.make().name().value().build(); </code></pre> <h3>Item Builder</h3> <pre><code>ItemBuilder.make().action() .attribute() .name().value().build() .attribute() .name().value().build() .build(); </code></pre> <h3>Order Builder</h3> <pre><code>OrderBuilder.make().action() .attribute() .name().value().build() .attribute() .name().value().build() .item() .action() .attribute() .name().value().build() .attribute() .name().value().build() .build() .build(); </code></pre> <p>We may later nest the Order Object in Some other object.</p> <p>So is there any way to achieve such nested DSL building ?</p>