public class FinalParametersCheck extends AbstractCheck
Check has an option ignorePrimitiveTypes which allows ignoring lack of final modifier at primitive data type parameter. Default value false.
E.g.:
private void foo(int x) { ... } //parameter is of primitive type
Modifier and Type | Field and Description |
---|---|
private boolean |
ignorePrimitiveTypes
Option to ignore primitive types as params.
|
static java.lang.String |
MSG_KEY
A key is pointing to the warning message text in "messages.properties"
file.
|
private java.util.Set<java.lang.Integer> |
primitiveDataTypes
Contains
primitive datatypes.
|
Constructor and Description |
---|
FinalParametersCheck() |
Modifier and Type | Method and Description |
---|---|
private void |
checkParam(DetailAST param)
Checks if the given parameter is final.
|
int[] |
getAcceptableTokens()
The configurable token set.
|
int[] |
getDefaultTokens()
Returns the default token a check is interested in.
|
int[] |
getRequiredTokens()
The tokens that this check must be registered for.
|
private boolean |
isIgnoredParam(DetailAST paramDef)
Checks for skip current param due to ignorePrimitiveTypes option.
|
void |
setIgnorePrimitiveTypes(boolean ignorePrimitiveTypes)
Sets ignoring primitive types as params.
|
private void |
visitCatch(DetailAST catchClause)
Checks parameter of the catch block.
|
private void |
visitForEachClause(DetailAST forEachClause)
Checks parameter of the for each clause.
|
private void |
visitMethod(DetailAST method)
Checks parameters of the method or ctor.
|
void |
visitToken(DetailAST ast)
Called to process a token.
|
beginTree, destroy, finishTree, getClassLoader, getFileContents, getLine, getLines, getTabWidth, getTokenNames, init, isCommentNodesRequired, leaveToken, log, log, setClassLoader, setFileContents, setMessages, setTabWidth, setTokens
getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, log, setId, setSeverity
configure, contextualize, finishLocalSetup, getConfiguration, setupChild
public static final java.lang.String MSG_KEY
private final java.util.Set<java.lang.Integer> primitiveDataTypes
private boolean ignorePrimitiveTypes
public void setIgnorePrimitiveTypes(boolean ignorePrimitiveTypes)
ignorePrimitiveTypes
- true or false.public int[] getDefaultTokens()
AbstractCheck
getDefaultTokens
in class AbstractCheck
TokenTypes
public int[] getAcceptableTokens()
AbstractCheck
getAcceptableTokens
in class AbstractCheck
TokenTypes
public int[] getRequiredTokens()
AbstractCheck
getRequiredTokens
in class AbstractCheck
TokenTypes
public void visitToken(DetailAST ast)
AbstractCheck
visitToken
in class AbstractCheck
ast
- the token to processprivate void visitMethod(DetailAST method)
method
- method or ctor to check.private void visitCatch(DetailAST catchClause)
catchClause
- catch block to check.private void visitForEachClause(DetailAST forEachClause)
forEachClause
- for each clause to check.private void checkParam(DetailAST param)
param
- parameter to check.private boolean isIgnoredParam(DetailAST paramDef)
paramDef
- PARAMETER_DEF