public class OuterTypeNumberCheck extends AbstractCheck
Checks for the number of types declared at the outer (or root) level in a file.
Rationale: It is considered good practice to only define one outer type per file.
max - Specify the maximum number of outer types allowed.
Type is int.
Default value is 1.
To configure the check to accept 1 outer type per file:
<module name="OuterTypeNumber"/>
To configure the check to accept 2 outer types per file:
<module name="OuterTypeNumber"> <property name="max" value="2"/> </module>
Parent is com.puppycrawl.tools.checkstyle.TreeWalker
Violation Message Keys:
maxOuterTypes
AutomaticBean.OutputStreamOptions| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
MSG_KEY
A key is pointing to the warning message text in "messages.properties"
file.
|
| Constructor and Description |
|---|
OuterTypeNumberCheck() |
| Modifier and Type | Method and Description |
|---|---|
void |
beginTree(DetailAST ast)
Called before the starting to process a tree.
|
void |
finishTree(DetailAST ast)
Called after finished processing a tree.
|
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 |
leaveToken(DetailAST ast)
Called after all the child nodes have been process.
|
void |
setMax(int max)
Setter to specify the maximum number of outer types allowed.
|
void |
visitToken(DetailAST ast)
Called to process a token.
|
clearMessages, destroy, getFileContents, getLine, getLines, getMessages, getTabWidth, getTokenNames, init, isCommentNodesRequired, log, log, log, setFileContents, setTabWidth, setTokensfinishLocalSetup, getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeverityconfigure, contextualize, getConfiguration, setupChildpublic static final java.lang.String MSG_KEY
public OuterTypeNumberCheck()
public int[] getDefaultTokens()
AbstractCheckgetDefaultTokens in class AbstractCheckTokenTypespublic int[] getAcceptableTokens()
AbstractCheckgetAcceptableTokens in class AbstractCheckTokenTypespublic int[] getRequiredTokens()
AbstractCheckgetRequiredTokens in class AbstractCheckTokenTypespublic void beginTree(DetailAST ast)
AbstractCheckbeginTree in class AbstractCheckast - the root of the treepublic void finishTree(DetailAST ast)
AbstractCheckfinishTree in class AbstractCheckast - the root of the treepublic void visitToken(DetailAST ast)
AbstractCheckvisitToken in class AbstractCheckast - the token to processpublic void leaveToken(DetailAST ast)
AbstractCheckleaveToken in class AbstractCheckast - the token leavingpublic void setMax(int max)
max - the new number.Copyright © 2001-2020. All Rights Reserved.