Search in sources :

Example 1 with GeneratedClassDeclaration

use of org.drools.modelcompiler.builder.generator.declaredtype.generator.GeneratedClassDeclaration in project drools by kiegroup.

the class POJOGenerator method createPOJO.

private void createPOJO(TypeDeclarationDescr typeDescr) {
    SafeTypeResolver typeResolver = new SafeTypeResolver(pkg.getTypeResolver());
    DescrTypeDefinition descrDeclaredTypeDefinition = new DescrTypeDefinition(packageDescr, typeDescr, typeResolver);
    descrDeclaredTypeDefinition.getErrors().forEach(builder::addBuilderResult);
    // Implemented types should be probably in
    ClassOrInterfaceDeclaration generatedClass = new GeneratedClassDeclaration(descrDeclaredTypeDefinition, MARKER_INTERFACES).toClassDeclaration();
    packageModel.addGeneratedPOJO(generatedClass);
    addTypeMetadata(typeDescr.getTypeName());
}
Also used : GeneratedClassDeclaration(org.drools.modelcompiler.builder.generator.declaredtype.generator.GeneratedClassDeclaration) ClassOrInterfaceDeclaration(com.github.javaparser.ast.body.ClassOrInterfaceDeclaration)

Example 2 with GeneratedClassDeclaration

use of org.drools.modelcompiler.builder.generator.declaredtype.generator.GeneratedClassDeclaration in project drools by kiegroup.

the class DMNTypeSafeTypeGenerator method generateSourceCodeOfAllTypes.

public Map<String, String> generateSourceCodeOfAllTypes() {
    Map<String, String> allSources = new HashMap<>();
    DMNTypeSafePackageName packageDeclaration = this.packageName.create(dmnModel);
    for (TypeDefinition typeDefinition : types) {
        ClassOrInterfaceDeclaration generatedClass = new GeneratedClassDeclaration(typeDefinition, Collections.emptyList()).toClassDeclaration();
        CompilationUnit cu = new CompilationUnit(packageDeclaration.packageName());
        cu.getPackageDeclaration().ifPresent(pd -> pd.setBlockComment(this.disclaimerMarker));
        cu.addType(generatedClass);
        LOG.debug("\n{}", cu);
        allSources.put(packageDeclaration.appendPackage(typeDefinition.getTypeName()), cu.toString());
    }
    return allSources;
}
Also used : CompilationUnit(com.github.javaparser.ast.CompilationUnit) GeneratedClassDeclaration(org.drools.modelcompiler.builder.generator.declaredtype.generator.GeneratedClassDeclaration) HashMap(java.util.HashMap) ClassOrInterfaceDeclaration(com.github.javaparser.ast.body.ClassOrInterfaceDeclaration) TypeDefinition(org.drools.modelcompiler.builder.generator.declaredtype.api.TypeDefinition)

Aggregations

ClassOrInterfaceDeclaration (com.github.javaparser.ast.body.ClassOrInterfaceDeclaration)2 GeneratedClassDeclaration (org.drools.modelcompiler.builder.generator.declaredtype.generator.GeneratedClassDeclaration)2 CompilationUnit (com.github.javaparser.ast.CompilationUnit)1 HashMap (java.util.HashMap)1 TypeDefinition (org.drools.modelcompiler.builder.generator.declaredtype.api.TypeDefinition)1