com.puppycrawl.tools.checkstyle.checks.design

Class MutableExceptionCheck

public final class MutableExceptionCheck extends AbstractFormatCheck

Ensures that exceptions (defined as any class name conforming to some regular expression) are immutable. That is, have only final fields.

Rationale: Exception instances should represent an error condition. Having non final fields not only allows the state to be modified by accident and therefore mask the original condition but also allows developers to accidentally forget to initialise state thereby leading to code catching the exception to draw incorrect conclusions based on the state.

Author: Simon Harris

Constructor Summary
MutableExceptionCheck()
Creates new instance of the check.
Method Summary
int[]getDefaultTokens()
{@inheritDoc}
int[]getRequiredTokens()
{@inheritDoc}
voidleaveToken(DetailAST aAST)
{@inheritDoc}
voidvisitToken(DetailAST aAST)
{@inheritDoc}

Constructor Detail

MutableExceptionCheck

public MutableExceptionCheck()
Creates new instance of the check.

Method Detail

getDefaultTokens

public int[] getDefaultTokens()
{@inheritDoc}

getRequiredTokens

public int[] getRequiredTokens()
{@inheritDoc}

leaveToken

public void leaveToken(DetailAST aAST)
{@inheritDoc}

visitToken

public void visitToken(DetailAST aAST)
{@inheritDoc}