Is there any way to define static final variables (effectively constants) in a Java enum declaration?
What I want is to define in one place the string literal value
Maybe you should considering breaking this enum into two fields: an enum and an int:
@RequiredArgsConstructor
public enum MyEnum {
BAR("Bar"),
FOO("Foo")
@Getter
private final String value;
}
And then use:
private MyEnum type;
private int value;
(You can put that into a class or not, whether it makes sense to you)