Since Checkstyle 5.2
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="Checker">
<module name="TreeWalker">
<module name="InnerTypeLast"/>
</module>
</module>
Example:
class Test1 {
private String s;
class InnerTest1 {}
public void test() {} // violation
}
class Test2 {
static {};
class InnerTest1 {}
public Test2() {} // violation
}
class Example1 {
private String s;
public void test() {}
class InnerTest1 {}
}
All messages can be customized if the default message doesn't suit you. Please see the documentation to learn how to.
com.puppycrawl.tools.checkstyle.checks.design