1 4 package net.sourceforge.pmd.rules.design; 5 6 import net.sourceforge.pmd.ast.SimpleNode; 7 import net.sourceforge.pmd.rules.AbstractInefficientZeroCheck; 8 import net.sourceforge.pmd.symboltable.NameOccurrence; 9 import net.sourceforge.pmd.util.CollectionUtil; 10 11 17 public class UseCollectionIsEmpty extends AbstractInefficientZeroCheck { 18 19 public boolean appliesToClassName(String name){ 20 return CollectionUtil.isCollectionType(name, true); 21 } 22 23 30 public boolean isTargetMethod(NameOccurrence occ) { 31 if (occ.getNameForWhichThisIsAQualifier() != null) { 32 if (((SimpleNode) occ.getLocation()).getImage().endsWith(".size")) { 33 return true; 34 } 35 } 36 return false; 37 } 38 } 39 | Popular Tags |