public class Example {
public static void main(String[] args) throws Exception {
Eventloop eventloop = Eventloop.create().withCurrentThread();
ActiveJGenerator generator = new ActiveJGenerator()
.generateClass("ExampleClass")
.withField("String", "name")
.withMethod("void", "printHello", methodBuilder ->
methodBuilder
.addStatement("System.out.println(\"Hello, \" + name + \"!\")")
);
Class<?> exampleClass = generator.loadClass();
Object instance = exampleClass.getDeclaredConstructor().newInstance();
Method printHelloMethod = exampleClass.getDeclaredMethod("printHello", null);
printHelloMethod.invoke(instance, null);
}
}