public final class MutableExceptionCheck extends AbstractFormatCheck
Ensures that exceptions (classes with names conforming to some regular expression and explicitly extending classes with names conforming to other regular expression) are immutable. That is, they 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.
| Constructor and Description |
|---|
MutableExceptionCheck()
Creates new instance of the check.
|
| Modifier and Type | Method and Description |
|---|---|
int[] |
getDefaultTokens()
Returns the default token a check is interested in.
|
int[] |
getRequiredTokens()
The tokens that this check must be registered for.
|
void |
leaveToken(DetailAST ast)
Called after all the child nodes have been process.
|
void |
setExtendedClassNameFormat(String extendedClassNameFormat)
Sets the format of extended class name to the specified regular expression.
|
void |
visitToken(DetailAST ast)
Called to process a token.
|
getFormat, getRegexp, setCompileFlags, setFormatbeginTree, destroy, finishTree, getAcceptableTokens, getClassLoader, getFileContents, getLine, getLines, getTabWidth, getTokenNames, init, isCommentNodesRequired, log, log, setClassLoader, setFileContents, setMessages, setTabWidth, setTokensgetCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, log, setId, setSeverityconfigure, contextualize, finishLocalSetup, getConfiguration, setupChildpublic MutableExceptionCheck()
public void setExtendedClassNameFormat(String extendedClassNameFormat)
extendedClassNameFormat - a String valuepublic int[] getDefaultTokens()
CheckgetDefaultTokens in class CheckTokenTypespublic int[] getRequiredTokens()
CheckgetRequiredTokens in class CheckTokenTypespublic void visitToken(DetailAST ast)
CheckvisitToken in class Checkast - the token to processpublic void leaveToken(DetailAST ast)
CheckleaveToken in class Checkast - the token leavingCopyright © 2001–2015. All rights reserved.