Since Checkstyle 5.0
Left angle bracket ("<"):
Right angle bracket (">"):
To configure the check:
<module name="Checker"> <module name="TreeWalker"> <module name="GenericWhitespace"/> </module> </module>
Examples with correct spacing:
class Example1 { List<String> l; public <T> void foo() {} List a = new ArrayList<>(); Map<Integer, String> m; HashSet<Integer> set; record License<T>() {} }
Examples with incorrect spacing:
class Example2 { List <String> l; // violation, "<" followed by whitespace public<T> void foo() {} // violation, "<" not preceded with whitespace List a = new ArrayList<> (); // violation, ">" followed by whitespace Map<Integer, String>m; // violation, ">" not followed by whitespace HashSet<Integer > set; // violation, ">" preceded with whitespace record License<T> () {} // violation, ">" followed by whitespace }
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.whitespace