use of org.drools.javaparser.ast.body.MethodDeclaration in project drools by kiegroup.
the class POJOGenerator method generateEqualsMethod.
private static MethodDeclaration generateEqualsMethod(String generatedClassName, List<Statement> equalsFieldStatement) {
NodeList<Statement> equalsStatements = nodeList(referenceEquals, classCheckEquals);
equalsStatements.add(classCastStatement(generatedClassName));
equalsStatements.add(parseStatement("if ( !super.equals( o ) ) return false;"));
equalsStatements.addAll(equalsFieldStatement);
equalsStatements.add(parseStatement("return true;"));
final Type returnType = JavaParser.parseType(boolean.class.getSimpleName());
final MethodDeclaration equals = new MethodDeclaration(EnumSet.of(Modifier.PUBLIC), returnType, EQUALS);
equals.addParameter(Object.class, "o");
equals.addAnnotation("Override");
equals.setBody(new BlockStmt(equalsStatements));
return equals;
}
Aggregations