public final class ThrowsCountCheck extends Check
Restricts throws statements to a specified count (default = 1).
Rationale: Exceptions form part of a methods interface. Declaring a method to throw too many differently rooted exceptions makes exception handling onerous and leads to poor programming practices such as catch (Exception). This check forces developers to put exceptions into a hierarchy such that in the simplest case, only one type of exception need be checked for by a caller but allows any sub-classes to be caught specifically if necessary.
| Constructor and Description |
|---|
ThrowsCountCheck()
Creates new instance of the check.
|
| Modifier and Type | Method and Description |
|---|---|
int[] |
getDefaultTokens()
Returns the default token a check is interested in.
|
int |
getMax()
Getter for max property.
|
int[] |
getRequiredTokens()
The tokens that this check must be registered for.
|
void |
setMax(int max)
Setter for max property.
|
void |
visitToken(DetailAST ast)
Called to process a token.
|
beginTree, destroy, finishTree, getAcceptableTokens, getClassLoader, getFileContents, getLine, getLines, getTabWidth, getTokenNames, init, isCommentNodesRequired, leaveToken, log, log, setClassLoader, setFileContents, setMessages, setTabWidth, setTokensgetCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, log, setId, setSeverityconfigure, contextualize, finishLocalSetup, getConfiguration, setupChildpublic ThrowsCountCheck()
public int[] getDefaultTokens()
CheckgetDefaultTokens in class CheckTokenTypespublic int[] getRequiredTokens()
CheckgetRequiredTokens in class CheckTokenTypespublic int getMax()
public void setMax(int max)
max - maximum allowed throws statements.public void visitToken(DetailAST ast)
CheckvisitToken in class Checkast - the token to processCopyright © 2001–2015. All rights reserved.