public class ArrayTypeStyleCheck extends AbstractCheck
Checks the style of array type definitions.
Some like Java style: public static void main(String[] args)
and some like C style: public static void main(String args[]).
By default the Check enforces Java style.
This check strictly enforces only Java style for method return types regardless
of the value for 'javaStyle'. For example, byte[] getData().
This is because C doesn't compile methods with array declarations on the name.
javaStyle - Control whether to enforce Java style (true) or C style (false).
Type is boolean.
Default value is true.
To configure the check to enforce Java style:
<module name="ArrayTypeStyle"/>
Example:
public class MyClass {
int[] nums; // OK
String strings[]; // violation
char[] toCharArray() { // OK
return null;
}
byte getData()[] { // violation
return null;
}
}
To configure the check to enforce C style:
<module name="ArrayTypeStyle"> <property name="javaStyle" value="false"/> </module>
Example:
public class MyClass {
int[] nums; // violation
String strings[]; // OK
char[] toCharArray() { // OK
return null;
}
byte getData()[] { // violation
return null;
}
}
Parent is com.puppycrawl.tools.checkstyle.TreeWalker
Violation Message Keys:
array.type.style
AutomaticBean.OutputStreamOptions| Modifier and Type | Field and Description |
|---|---|
static String |
MSG_KEY
A key is pointing to the warning message text in "messages.properties"
file.
|
| Constructor and Description |
|---|
ArrayTypeStyleCheck() |
| 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.
|
void |
setJavaStyle(boolean javaStyle)
Setter to control whether to enforce Java style (true) or C style (false).
|
void |
visitToken(DetailAST ast)
Called to process a token.
|
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, setSeverityconfigure, contextualize, getConfiguration, setupChildpublic static final String MSG_KEY
public ArrayTypeStyleCheck()
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 AbstractCheckast - the token to processpublic void setJavaStyle(boolean javaStyle)
javaStyle - true if Java style should be used.Copyright © 2001–2020. All rights reserved.