com.puppycrawl.tools.checkstyle.checks.modifier

Class ModifierOrderCheck

Implemented Interfaces:
Configurable, Contextualizable

public class ModifierOrderCheck
extends Check

Checks that the order of modifiers conforms to the suggestions in the Java Language specification, sections 8.1.1, 8.3.1 and 8.4.3. The correct order is:
  1. public
  2. protected
  3. private
  4. abstract
  5. static
  6. final
  7. transient
  8. volatile
  9. synchronized
  10. native
  11. strictfp
In additional, modifiers are checked to ensure all annotations are declared before all other modifiers.

Rationale: Code is easier to read if everybody follows a standard.

An example of how to configure the check is:

 <module name="ModifierOrder"/>
 
Author:
Lars Kühne

Method Summary

int[]
getDefaultTokens()
void
visitToken(DetailAST aAST)

Methods inherited from class com.puppycrawl.tools.checkstyle.api.Check

beginTree, destroy, finishTree, getAcceptableTokens, getClassLoader, getDefaultTokens, getFileContents, getLines, getRequiredTokens, getTabWidth, getTokenNames, init, leaveToken, log, log, setClassLoader, setFileContents, setMessages, setTabWidth, setTokens, visitToken

Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter

getId, getMessageBundle, getSeverity, getSeverityLevel, log, log, log, log, log, log, log, log, log, log, log, setId, setSeverity

Methods inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean

configure, contextualize, finishLocalSetup, getConfiguration, setupChild

Method Details

getDefaultTokens

public int[] getDefaultTokens()
Overrides:
getDefaultTokens in interface Check

visitToken

public void visitToken(DetailAST aAST)
Overrides:
visitToken in interface Check