@Override public BlockStmt doMerge(BlockStmt first, BlockStmt second) { BlockStmt bs = new BlockStmt(); bs.setStmts(mergeCollectionsInOrder(first.getStmts(),second.getStmts())); return bs; }
private MethodDeclaration getterDeclaration(EntityField field) { MethodDeclaration decl = new MethodDeclaration(ModifierSet.PUBLIC, ASTHelper.createReferenceType(field.getType().getSimpleName(), 0), "get" + CaseConverter.pascalCase(field.getName())); BlockStmt body = new BlockStmt(); body.setStmts( Collections.singletonList( new ReturnStmt( new FieldAccessExpr(new ThisExpr(), field.getName())))); decl.setBody(body); return decl; }
public static BlockStmt mergeBlock(BlockStmt one, BlockStmt two) { if (isAllNull(one, two)) return null; BlockStmt blockStmt = null; if (isAllNotNull(one, two)) { blockStmt = new BlockStmt(); blockStmt.setComment(mergeSelective(one.getComment(), two.getComment())); blockStmt.setStmts(mergeListInOrder(one.getStmts(), two.getStmts())); } else { blockStmt = findFirstNotNull(one, two); } return blockStmt; }
private MethodDeclaration setterDeclaration(EntityField field) { MethodDeclaration decl = new MethodDeclaration(ModifierSet.PUBLIC, new VoidType(), "set" + CaseConverter.pascalCase(field.getName()), Collections.singletonList(new Parameter( ASTHelper.createReferenceType(field.getType().getSimpleName(), 0), new VariableDeclaratorId(field.getName())))); BlockStmt body = new BlockStmt(); body.setStmts( Collections.singletonList( new ExpressionStmt( new AssignExpr( new FieldAccessExpr(new ThisExpr(), field.getName()), ASTHelper.createNameExpr(field.getName()), AssignExpr.Operator.assign )))); decl.setBody(body); return decl; }