public class RecordComponentNameCheck extends AbstractNameCheck
Checks that record component names conform to a specified pattern.
format - Specifies valid identifiers.
Type is java.util.regex.Pattern.
Default value is "^[a-z][a-zA-Z0-9]*$".
To configure the check:
<module name="RecordComponentName"/>
Example:
record MyRecord1(String value, int otherComponentName) {} // OK
record MyRecord2(String... Values) {} // violation, the record component name
// should match the regular expression "^[a-z][a-zA-Z0-9]*$"
record MyRecord3(double my_number) {} // violation, the record component name
// should match the regular expression "^[a-z][a-zA-Z0-9]*$"
An example of how to configure the check for names that are only letters in lowercase:
Configuration:
<module name="RecordComponentName"> <property name="format" value="^[a-z]+$"/> </module>
Example:
record MyRecord1(String value, int other) {} // OK
record MyRecord2(String... strings) {} // OK
record MyRecord3(double myNumber) {} // violation, the record component name
// should match the regular expression "^[a-z]+$"
Parent is com.puppycrawl.tools.checkstyle.TreeWalker
Violation Message Keys:
name.invalidPattern
AutomaticBean.OutputStreamOptionsMSG_INVALID_PATTERN| Constructor and Description |
|---|
RecordComponentNameCheck()
Creates a new
RecordComponentNameCheck instance. |
| Modifier and Type | Method and Description |
|---|---|
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.
|
protected boolean |
mustCheckName(DetailAST ast)
Decides whether the name of an AST should be checked against
the format regexp.
|
setFormat, visitTokenbeginTree, clearViolations, destroy, finishTree, getFileContents, getLine, getLineCodePoints, getLines, getTabWidth, getTokenNames, getViolations, init, isCommentNodesRequired, leaveToken, log, log, log, setFileContents, setTabWidth, setTokensfinishLocalSetup, getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeverityconfigure, contextualize, getConfiguration, setupChildpublic RecordComponentNameCheck()
RecordComponentNameCheck instance.public int[] getDefaultTokens()
AbstractCheckgetDefaultTokens in class AbstractCheckTokenTypespublic final int[] getAcceptableTokens()
AbstractCheckgetAcceptableTokens in class AbstractCheckTokenTypespublic int[] getRequiredTokens()
AbstractCheckgetRequiredTokens in class AbstractCheckTokenTypesprotected final boolean mustCheckName(DetailAST ast)
AbstractNameCheckmustCheckName in class AbstractNameCheckast - the AST to check.Copyright © 2001-2022. All Rights Reserved.