RSPEC-1214: Should ignore local/inner Constants Interfaces

Version used: Community Edition, Version 8.9.1 (build 44547)
Code sample:

public class MyEntity {

	public interface Columns {
		String FOO_BAR = "FOO_BAR";
	@Column(name = Columns.FOO_BAR)
	private String fooBar;


Hi, we are using constants to map database columns to Java code. This way we can avoid duplicates and have strong binding. We decided to use Constants Interface pattern, because it’s more compact than a Class. Could we ignore RSPEC-1214 by default if constants are defined in local/inner interface?

Inner class with a private constructor is just too wordy/boilerplate → public static final. The interface is brief. It seems to me that Bloch (see the example in the book) was about public interfaces that are part of an external API, not those that are only needed within the application and are simplifying things.

Hello @RG9

This rule reports the usage of the Constants Interface Pattern, if you are fully convinced that using it here is fine in this case, you should simply consider marking the issue as “Won’t fix”.

Does it clarify the situation?


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.