public class InnerTypeLastCheck extends AbstractCheck
Checks nested (internal) classes/interfaces are declared at the bottom of the primary (top-level) class after all init and static init blocks, method, constructor and field declarations.
To configure the check:
<module name="InnerTypeLast"/>
Example:
class Test {
private String s; // OK
class InnerTest1 {}
public void test() {} // violation, method should be declared before inner types.
}
class Test2 {
static {}; // OK
class InnerTest1 {}
public Test2() {} // violation, constructor should be declared before inner types.
}
class Test3 {
private String s; // OK
public void test() {} // OK
class InnerTest1 {}
}
Parent is com.puppycrawl.tools.checkstyle.TreeWalker
Violation Message Keys:
arrangement.members.before.inner
AutomaticBean.OutputStreamOptions| Modifier and Type | Field and Description |
|---|---|
private static java.util.List<java.lang.Integer> |
CLASS_MEMBER_TOKENS
List of class member tokens.
|
static java.lang.String |
MSG_KEY
A key is pointing to the warning message text in "messages.properties"
file.
|
private boolean |
rootClass
Meet a root class.
|
| Constructor and Description |
|---|
InnerTypeLastCheck() |
| Modifier and Type | Method and Description |
|---|---|
void |
beginTree(DetailAST rootAST)
Called before the starting to process 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 |
visitToken(DetailAST ast)
Called to process a token.
|
clearViolations, destroy, finishTree, getFileContents, getLine, getLineCodePoints, getLines, getTabWidth, getTokenNames, getViolations, 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
private static final java.util.List<java.lang.Integer> CLASS_MEMBER_TOKENS
private boolean rootClass
public InnerTypeLastCheck()
public int[] getDefaultTokens()
AbstractCheckgetDefaultTokens in class AbstractCheckTokenTypespublic int[] getAcceptableTokens()
AbstractCheckgetAcceptableTokens in class AbstractCheckTokenTypespublic int[] getRequiredTokens()
AbstractCheckgetRequiredTokens in class AbstractCheckTokenTypespublic void beginTree(DetailAST rootAST)
AbstractCheckbeginTree in class AbstractCheckrootAST - 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 leavingCopyright © 2001-2022. All Rights Reserved.