public class SimpleAccessorNameNotationCheck
extends com.puppycrawl.tools.checkstyle.api.AbstractCheck
This check verify incorrect name of setter and getter methods if it used field with other name.
For example, method has name 'setXXX', but define field with name 'YYY'. Setter and getter methods must have next view: XXXType getXXXName() {return XXXName} XXXType getXXXName() {return this.XXXName} void setXXXName(XXXType value) { this.XXXName = value} void setXXXName(XXXType value) { XXXName = value}
If name of field contains prefix,then must to be define parameter 'prefix' , for example:
<module name="SimpleAccessorNameNotationCheck"> < property name="prefix" value="m_"/> </module>
| Modifier and Type | Field and Description |
|---|---|
static String |
MSG_KEY_GETTER
A key is pointing to the warning message text in "messages.properties"
file.
|
static String |
MSG_KEY_SETTER
A key is pointing to the warning message text in "messages.properties"
file.
|
| Constructor and Description |
|---|
SimpleAccessorNameNotationCheck() |
| Modifier and Type | Method and Description |
|---|---|
int[] |
getAcceptableTokens() |
int[] |
getDefaultTokens() |
int[] |
getRequiredTokens() |
void |
setPrefix(String prefix)
Setter for prefix.
|
void |
visitToken(com.puppycrawl.tools.checkstyle.api.DetailAST methodDef) |
beginTree, clearMessages, destroy, finishTree, getFileContents, getLine, getLines, getMessages, getTabWidth, getTokenNames, init, isCommentNodesRequired, leaveToken, log, log, log, setFileContents, setTabWidth, setTokensfinishLocalSetup, getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeveritypublic static final String MSG_KEY_GETTER
public static final String MSG_KEY_SETTER
public void setPrefix(String prefix)
prefix - - prefix of field's namepublic int[] getDefaultTokens()
getDefaultTokens in class com.puppycrawl.tools.checkstyle.api.AbstractCheckpublic int[] getAcceptableTokens()
getAcceptableTokens in class com.puppycrawl.tools.checkstyle.api.AbstractCheckpublic int[] getRequiredTokens()
getRequiredTokens in class com.puppycrawl.tools.checkstyle.api.AbstractCheckpublic void visitToken(com.puppycrawl.tools.checkstyle.api.DetailAST methodDef)
visitToken in class com.puppycrawl.tools.checkstyle.api.AbstractCheckCopyright © 2021. All rights reserved.