findChildrenOfType never returns null; it just returns an empty List if there aren't any found

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@4758 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Tom Copeland
2006-10-29 20:04:12 +00:00
parent da00dd2a2b
commit 15d1c24887
2 changed files with 3 additions and 6 deletions

View File

@ -36,7 +36,7 @@ public class AbstractOptimizationRule extends AbstractRule implements Rule {
// TODO - symbol table?
protected final String getVarName(ASTLocalVariableDeclaration node) {
List l = node.findChildrenOfType(ASTVariableDeclaratorId.class);
if (l != null && !l.isEmpty()) {
if (!l.isEmpty()) {
ASTVariableDeclaratorId vd = (ASTVariableDeclaratorId) l.get(0);
return vd.getImage();
}

View File

@ -44,7 +44,7 @@ public class ExceptionSignatureDeclaration extends AbstractRule {
}
List exceptionList = methodDeclaration.findChildrenOfType(ASTName.class);
if (!hasContent(exceptionList)) {
if (!!exceptionList.isEmpty()) {
return super.visit(methodDeclaration, o);
}
@ -55,7 +55,7 @@ public class ExceptionSignatureDeclaration extends AbstractRule {
public Object visit(ASTConstructorDeclaration constructorDeclaration, Object o) {
List exceptionList = constructorDeclaration.findChildrenOfType(ASTName.class);
if (!hasContent(exceptionList)) {
if (!!exceptionList.isEmpty()) {
return super.visit(constructorDeclaration, o);
}
@ -99,7 +99,4 @@ public class ExceptionSignatureDeclaration extends AbstractRule {
return parent instanceof ASTMethodDeclaration || parent instanceof ASTConstructorDeclaration;
}
private boolean hasContent(List nameList) {
return nameList != null && !nameList.isEmpty();
}
}