InnerTypeLast

Since Checkstyle 5.2

Description

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.

Examples

To configure the check:

<module name="Checker">
  <module name="TreeWalker">
    <module name="InnerTypeLast"/>
  </module>
</module>
        

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 {}
}
        

Example of Usage

Violation Messages

All messages can be customized if the default message doesn't suit you. Please see the documentation to learn how to.

Package

com.puppycrawl.tools.checkstyle.checks.design

Parent Module

TreeWalker