Since Checkstyle 5.8
To configure the check:
<module name="Checker">
<module name="TreeWalker">
<module name="OneTopLevelClass"/>
</module>
</module>
ATTENTION: This Check does not support customization of validated tokens, so do not use the "tokens" property.
An example of code with violations:
public class Example1 { // OK, first top-level class
// methods
}
class ViolationExample1 { // violation, "has to reside in its own source file."
// methods
}
An example of code without public top-level type:
class Example2 { // OK, first top-level class
// methods
}
class ViolationExample2 { // violation, "has to reside in its own source file."
// methods
}
An example of code without violations:
public class Example3 { // OK, only one top-level class
// methods
}
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