1 /***
2 * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3 */
4 package net.sourceforge.pmd.rules;
5
6 import net.sourceforge.pmd.AbstractRule;
7 import net.sourceforge.pmd.RuleContext;
8 import net.sourceforge.pmd.ast.ASTConstructorDeclaration;
9 import net.sourceforge.pmd.ast.ASTUnmodifiedClassDeclaration;
10
11 import java.util.ArrayList;
12 import java.util.List;
13
14 public class AtLeastOneConstructorRule extends AbstractRule {
15
16 public Object visit(ASTUnmodifiedClassDeclaration node, Object data) {
17 List constructors = new ArrayList();
18 node.findChildrenOfType(ASTConstructorDeclaration.class, constructors, false);
19 if (constructors.isEmpty()) {
20 RuleContext ctx = (RuleContext) data;
21 ctx.getReport().addRuleViolation(createRuleViolation(ctx, node.getBeginLine()));
22 }
23 return super.visit(node, data);
24 }
25 }
This page was automatically generated by Maven