FormTask implements GenTask { @Override public void execute(PathResolver pathResolver) throws Exception { CompilationUnit cu = new CompilationUnit(); String basePackage = BasePackageDetector.detect(); cu.setPackage(new PackageDeclaration(ASTHelper.createNameExpr(basePackage + "form"))); ClassOrInterfaceDeclaration formClass = new ClassOrInterfaceDeclaration( ModifierSet.PUBLIC, false, CaseConverter.pascalCase(tableName) + "Form"); ASTHelper.addTypeDeclaration(cu, formClass); formClass.setExtends(Collections.singletonList( new ClassOrInterfaceType("FormBase") )); fields.stream() .filter(f -> !f.isId()) .forEach(f -> ASTHelper.addMember(formClass, fieldDeclaration(f))); fields.stream() .filter(f -> !f.isId()) .forEach(f -> ASTHelper.addMember(formClass, getterDeclaration(f))); fields.stream() .filter(f -> !f.isId()) .forEach(f -> ASTHelper.addMember(formClass, setterDeclaration(f))); try (Writer writer = new OutputStreamWriter(pathResolver.destinationAsStream(destination))) { writer.write(cu.toString()); } } FormTask(String pkgName, String tableName, List<EntityField> fields); @Override void execute(PathResolver pathResolver); @Override String getDestinationPath();  }
@Test void test() throws Exception { FormTask task = new FormTask("", "Product", Arrays.asList( new EntityField("id", Long.class, true), new EntityField("name", String.class, false), new EntityField("email", String.class, false) )); PathResolverMock pathResolver = new PathResolverMock(); task.execute(pathResolver); }