public class ClassWithConstants {
public static final int MIN_CONSTS = 0;
public static final int CONST1 = 0;
public static final int CONST2 = 1;
public static final int MAX_CONSTS = 2;
private void validateConstant(int constant) throws IllegalConstantException{
if(constant < MIN_CONSTS || constant >= MAX_CONSTS){
throw new IllegalConstantException();
}
}
}
class IllegalConstantException extends Exception{
}