Update on 2026-05-14: Rather than creating a new rule to address this, this case is now considered as a false-negative for UseUtilityClass.
Rule: UseUtilityClass
Equivalent rule to java-design/UseUtilityClass but for classes that just have public constants.
These types have no behavior and should not be instantiable.
If the class extends another / implements interfaces, no warning should be added (behavior may be present on parent class / default methods on interface).
Code Sample demonstrating the issue:
public class Constants {
public static final String MAILING_FROM = "noreply@mycompany.com";
public static final String USER_AGENT = "mycompany/spider 1.0"
}
Notice we only mark classes. For interfaces there is already a rule java-design/ConstantsInInterface
Update on 2026-05-14: Rather than creating a new rule to address this, this case is now considered as a false-negative for UseUtilityClass.
Rule: UseUtilityClass
Equivalent rule to
java-design/UseUtilityClassbut for classes that just have public constants.These types have no behavior and should not be instantiable.
If the class extends another / implements interfaces, no warning should be added (behavior may be present on parent class / default methods on interface).
Code Sample demonstrating the issue:
Notice we only mark classes. For interfaces there is already a rule
java-design/ConstantsInInterface