public class MethodTypeParameterNameCheck extends AbstractNameCheck
Checks that method type parameter names conform to a specified pattern.
format - Specifies valid identifiers.
Type is java.util.regex.Pattern.
Default value is "^[A-Z]$".
To configure the check:
<module name="MethodTypeParameterName"/>
Code Example:
class MyClass {
public <T> void method1() {} // OK
public <a> void method2() {} // violation, name 'a' must match pattern '^[A-Z]$'
public <K, V> void method3() {} // OK
public <k, V> void method4() {} // violation, name 'k' must match pattern '^[A-Z]$'
}
An example of how to configure the check for names that are only a single letter is:
<module name="MethodTypeParameterName">
<property name="format" value="^[a-zA-Z]$"/>
</module>
Code Example:
class MyClass {
public <T> void method1() {} // OK
public <a> void method2() {} // OK
public <K, V> void method3() {} // OK
public <k, V> void method4() {} // OK
}
Parent is com.puppycrawl.tools.checkstyle.TreeWalker
Violation Message Keys:
name.invalidPattern
AutomaticBean.OutputStreamOptionsMSG_INVALID_PATTERN| Constructor and Description |
|---|
MethodTypeParameterNameCheck()
Creates a new
MethodTypeParameterNameCheck 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, clearMessages, destroy, finishTree, getFileContents, getLine, getLines, getMessages, getTabWidth, getTokenNames, init, isCommentNodesRequired, leaveToken, log, log, log, setFileContents, setTabWidth, setTokensfinishLocalSetup, getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeverityconfigure, contextualize, getConfiguration, setupChildpublic MethodTypeParameterNameCheck()
MethodTypeParameterNameCheck instance.public int[] getDefaultTokens()
AbstractCheckgetDefaultTokens in class AbstractCheckTokenTypespublic 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-2020. All Rights Reserved.