Class OuterTypeFilenameCheck

  • All Implemented Interfaces:
    Configurable, Contextualizable

    public class OuterTypeFilenameCheck
    extends AbstractCheck

    Checks that the outer type name and the file name match. For example, the class Foo must be in a file named Foo.java.

    To configure the check:

     <module name="OuterTypeFilename"/>
     

    Example of class Test in a file named Test.java

     public class Test { // OK
    
     }
     

    Example of class Foo in a file named Test.java

     class Foo { // violation
    
     }
     

    Example of interface Foo in a file named Test.java

     interface Foo { // violation
    
     }
     

    Example of enum Foo in a file named Test.java

     enum Foo { // violation
    
     }
     

    Example of record Foo in a file named Test.java

     record Foo { // violation
    
     }
     

    Parent is com.puppycrawl.tools.checkstyle.TreeWalker

    Violation Message Keys:

    • type.file.mismatch
    Since:
    5.3