forked from phoedos/pmd
Add property to ignore interfaces in FieldDeclarationsShouldBeAtStartOfClassRule
This commit is contained in:
@ -40,6 +40,8 @@ public class FieldDeclarationsShouldBeAtStartOfClassRule extends AbstractJavaRul
|
||||
"Ignore Enum Declarations that precede fields.", true, 1.0f);
|
||||
private BooleanProperty ignoreAnonymousClassDeclarations = new BooleanProperty("ignoreAnonymousClassDeclarations",
|
||||
"Ignore Field Declarations, that are initialized with anonymous class declarations", true, 2.0f);
|
||||
private BooleanProperty ignoreInterfaceDeclarations = new BooleanProperty("ignoreInterfaceDeclarations",
|
||||
"Ignore Interface Declarations that precede fields.", false, 3.0f);
|
||||
|
||||
/**
|
||||
* Initializes the rule {@link FieldDeclarationsShouldBeAtStartOfClassRule}.
|
||||
@ -67,11 +69,20 @@ public class FieldDeclarationsShouldBeAtStartOfClassRule extends AbstractJavaRul
|
||||
&& getProperty(ignoreAnonymousClassDeclarations).booleanValue()) {
|
||||
continue;
|
||||
}
|
||||
if (child instanceof ASTClassOrInterfaceDeclaration || child instanceof ASTMethodDeclaration
|
||||
|| child instanceof ASTConstructorDeclaration || child instanceof ASTAnnotationTypeDeclaration) {
|
||||
if (child instanceof ASTMethodDeclaration || child instanceof ASTConstructorDeclaration
|
||||
|| child instanceof ASTAnnotationTypeDeclaration) {
|
||||
addViolation(data, node);
|
||||
break;
|
||||
}
|
||||
if (child instanceof ASTClassOrInterfaceDeclaration) {
|
||||
ASTClassOrInterfaceDeclaration declaration = (ASTClassOrInterfaceDeclaration) child;
|
||||
if (declaration.isInterface() && getProperty(ignoreInterfaceDeclarations).booleanValue()) {
|
||||
continue;
|
||||
} else {
|
||||
addViolation(data, node);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (child instanceof ASTEnumDeclaration && !getProperty(ignoreEnumDeclarations).booleanValue()) {
|
||||
addViolation(data, node);
|
||||
break;
|
||||
|
Reference in New Issue
Block a user