There are a number of options out there to programmatically create Java code. Most notably, there is Javapoet.
However, sometimes you just can't help using JDT. Maybe you are developing an Eclipse plugin? Maybe you want to leverage one of the numerous features of JDT?
Either way, if you are stuck with JDT, you will have to be prepared to do lots of typing. Or, you know, just use Fluentast and save you some hassle. I mean, have you looked at the example above?
The most common syntax elements, such as if-statements, loops, variable assignments and so forth are supported. However, there might still be some missing.
For an overview of supported syntax elements please see the supported syntax elements documentation.
Creating an abstract syntax tree is still to cumbersome? You may simple add blocks and statements as strings and mix them with other fluent elements.
Have a look at the demo project.
There is still a lot of work to do. Add fluent interfaces for not-yet supported types or even add entirely new capabilities: Your contributions are
certainly welcome! Have a look at the repository.