Example:
public enum TestEnum {
FOO(4), BAR(7);
public final int externalValue;
private TestEnum(int externalValue) {
this.externalValue = externalValue;
}
}
Notice how there is no getExternalValue() method. Since the externalValue field is final, there's no risk of it getting modified. Running code like this through Sonar gives me a "Variable 'externalValue' must be private and have accessor methods" error.
Assume I'm a total moron, and explain: why do I absolutely need to implement and use an accessor for externalValue?
It's difficult to explain why, but the way the Java Bean pattern went from a clever construct to being a universal law, somehow upsets me. I just feel it shouldn't have to be necessary always.