forked from phoedos/pmd
Checking in some Java 5 changes
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@5021 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
@ -40,7 +40,7 @@ public class BrokenNullCheck extends AbstractRule {
|
||||
|
||||
|
||||
private void checkForViolations(ASTIfStatement node, Object data, SimpleJavaNode conditionalExpression) {
|
||||
ASTEqualityExpression equalityExpression = (ASTEqualityExpression)getFirstDirectChildOfType(ASTEqualityExpression.class, conditionalExpression);
|
||||
ASTEqualityExpression equalityExpression = getFirstDirectChildOfType(ASTEqualityExpression.class, conditionalExpression);
|
||||
if (equalityExpression == null) {
|
||||
return;
|
||||
}
|
||||
@ -164,11 +164,11 @@ public class BrokenNullCheck extends AbstractRule {
|
||||
return null; //Nothing found
|
||||
}
|
||||
|
||||
private Node getFirstDirectChildOfType(Class childType, Node node) {
|
||||
private <T> T getFirstDirectChildOfType(Class<T> childType, Node node) {
|
||||
for (int i = 0; i < node.jjtGetNumChildren(); i++) {
|
||||
SimpleJavaNode simpleNode = (SimpleJavaNode) node.jjtGetChild(i);
|
||||
if (simpleNode.getClass().equals(childType))
|
||||
return simpleNode;
|
||||
return (T)simpleNode;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
Reference in New Issue
Block a user