public class AlphabeticallyOrderedDefinitionsCheck
extends com.puppycrawl.tools.checkstyle.api.AbstractCheck
The configuration checks the ordering of variable and method definitions under classes and interfaces.
<module name="AlphabeticallyOrderedDefinitions"/>This check will error on a definition's line if it should be alphabetically before the last definition that has the same modifiers.
To specify non-access modifiers to ignore, you can configure the ignoredModifiers property with
final, static,
transient, native,
synchronized, volatile,
abstract, strictfp,
default, and annotation.
For simplicity regarding the annotation modifier, the current implementation only checks whether a definition is
annotated and does not check what annotations the definition has, so if two definitions have the same modifiers and
one is annotated with @Override and the other with @Nonnull, they'll still be compared.
For example, the following configuration will check that definitions that have the same modifiers, but ignoring whether they have static or final modifiers in common, are alphabetically ordered.
<module name="AlphabeticallyOrderedDefinitions">
<property name="ignoredModifiers" value="static, final"/>
</module>
| Constructor and Description |
|---|
AlphabeticallyOrderedDefinitionsCheck() |
| Modifier and Type | Method and Description |
|---|---|
int[] |
getAcceptableTokens() |
int[] |
getDefaultTokens() |
int[] |
getRequiredTokens() |
void |
setIgnoredModifiers(String[] modifiers) |
void |
visitToken(com.puppycrawl.tools.checkstyle.api.DetailAST ast) |
beginTree, clearViolations, destroy, finishTree, getFileContents, getLine, getLines, getTabWidth, getTokenNames, getViolations, init, isCommentNodesRequired, leaveToken, log, log, log, setFileContents, setTabWidth, setTokensfinishLocalSetup, getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeveritypublic AlphabeticallyOrderedDefinitionsCheck()
public int[] getDefaultTokens()
getDefaultTokens in class com.puppycrawl.tools.checkstyle.api.AbstractCheckpublic int[] getAcceptableTokens()
getAcceptableTokens in class com.puppycrawl.tools.checkstyle.api.AbstractCheckpublic int[] getRequiredTokens()
getRequiredTokens in class com.puppycrawl.tools.checkstyle.api.AbstractCheckpublic void setIgnoredModifiers(String[] modifiers)
public void visitToken(com.puppycrawl.tools.checkstyle.api.DetailAST ast)
visitToken in class com.puppycrawl.tools.checkstyle.api.AbstractCheckCopyright © 2022 Atlassian. All rights reserved.