public class LambdaParameterNameCheck extends AbstractNameCheck
Check to verify lambda parameter names.
format - Specifies valid identifiers.
Default value is "^[a-z][a-zA-Z0-9]*$".
An example of how to configure the check is:
<module name="LambdaParameterName"/>
An example of how to configure the check for names that begin with a lower case letter, followed by letters is:
<module name="LambdaParameterName"> <property name="format" value="^[a-z]([a-zA-Z]+)*$"/> </module>
Example of checking with this config:
public class TestClass {
Function<String, String> function1 = str -> str.toUpperCase().trim();
Function<String, String> function2 = _s -> _s.trim().toUpperCase(); // violation
public boolean testMethod(String sentence) {
return Stream.of(sentence.split(" "))
.map(word -> word.trim())
.anyMatch(Word -> "in".equals(Word)); // violation
}
}
AutomaticBean.OutputStreamOptionsMSG_INVALID_PATTERN| Constructor and Description |
|---|
LambdaParameterNameCheck()
Creates new instance of
LambdaParameterNameCheck. |
| 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.
|
void |
visitToken(DetailAST ast)
Called to process a token.
|
setFormatbeginTree, 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 LambdaParameterNameCheck()
LambdaParameterNameCheck.public int[] getDefaultTokens()
AbstractCheckgetDefaultTokens in class AbstractCheckTokenTypespublic int[] getAcceptableTokens()
AbstractCheckgetAcceptableTokens in class AbstractCheckTokenTypespublic int[] getRequiredTokens()
AbstractCheckgetRequiredTokens in class AbstractCheckTokenTypespublic void visitToken(DetailAST ast)
AbstractCheckvisitToken in class AbstractNameCheckast - the token to processprotected boolean mustCheckName(DetailAST ast)
AbstractNameCheckmustCheckName in class AbstractNameCheckast - the AST to check.Copyright © 2001-2019. All Rights Reserved.