net.sourceforge.pmd.rules.design

Class UseCollectionIsEmpty

public class UseCollectionIsEmpty extends AbstractInefficientZeroCheck

Detect structures like "foo.size() == 0" and suggest replacing them with foo.isEmpty(). Will also find != 0 (replacable with !isEmpty()).

Author: Jason Bennett

Method Summary
booleanappliesToClassName(String name)
booleanisTargetMethod(NameOccurrence occ)
Determine if we're dealing with .size method

Method Detail

appliesToClassName

public boolean appliesToClassName(String name)

isTargetMethod

public boolean isTargetMethod(NameOccurrence occ)
Determine if we're dealing with .size method

Parameters: occ The name occurance

Returns: true if it's .length, else false