Class InnerTypeLastCheck

  • All Implemented Interfaces:
    Configurable, Contextualizable

    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
    Since:
    5.2