use of org.drools.modelcompiler.builder.generator.declaredtype.api.MethodParameter in project drools by kiegroup.
the class GeneratedClassDeclaration method addMethod.
private void addMethod(MethodDefinition methodDefinition) {
List<Modifier.Keyword> modifiers = new ArrayList<>();
if (methodDefinition.isStatic()) {
modifiers.add(Modifier.Keyword.STATIC);
}
if (methodDefinition.isPublic()) {
modifiers.add(Modifier.Keyword.PUBLIC);
}
MethodDeclaration methodDeclaration = generatedClass.addMethod(methodDefinition.getMethodName(), modifiers.toArray(new Modifier.Keyword[0]));
methodDeclaration.setType(methodDefinition.getReturnType());
for (MethodParameter mp : methodDefinition.parameters()) {
methodDeclaration.addParameter(mp.getType(), mp.getName());
}
for (AnnotationDefinition a : methodDefinition.getAnnotations()) {
methodDeclaration.addAnnotation(createSimpleAnnotation(a.getName()));
}
methodDeclaration.setBody(StaticJavaParser.parseBlock(methodDefinition.getBody()));
}
Aggregations