Lets say I've this code:
public class MyClass { public final static int valueA = 0; public final static int valueB = 1; private int parameter = -1; public MyClass(int parameter) { if(parameter != valueA && parameter != valueB) { throw new IllegalArgumentException("Exception description here"); } this.parameter = parameter; } } Is this a best practice? Or is there a better way to grantee that whatever the value passed on the constructor it has the same value as one of those variables?