com.puppycrawl.tools.checkstyle.checks.coding

Class EqualsHashCodeCheck

public class EqualsHashCodeCheck extends Check

Checks that classes that override equals() also override hashCode().

Rationale: The contract of equals() and hashCode() requires that equal objects have the same hashCode. Hence, whenever you override equals() you must override hashCode() to ensure that your class can be used in collections that are hash based.

An example of how to configure the check is:

 <module name="EqualsHashCode"/>
 

Author: lkuehne

Method Summary
voidbeginTree(DetailAST aRootAST)
{@inheritDoc}
voidfinishTree(DetailAST aRootAST)
{@inheritDoc}
int[]getDefaultTokens()
{@inheritDoc}
voidvisitToken(DetailAST aAST)
{@inheritDoc}

Method Detail

beginTree

public void beginTree(DetailAST aRootAST)
{@inheritDoc}

finishTree

public void finishTree(DetailAST aRootAST)
{@inheritDoc}

getDefaultTokens

public int[] getDefaultTokens()
{@inheritDoc}

visitToken

public void visitToken(DetailAST aAST)
{@inheritDoc}