I have a constant in my project, that represents some timespan. When it is below 0, I want to disable the timespan related checks.
Normally one would check
if(CONSTANT > 0) foo();
else bar();
but this causes the warning "Condition is always 'false'" or "Condition is always 'true'" depending on the value of the constant.
Is there a way to circumvent this warning, to prevent another dev to just that lines?
EDIT: I was a bit too generic with my question. Sorry about that.
I'm having a Timer, that after some time TIME_FOR_AUTH (the constant) has passed, clears my model. This is a security measure, that makes problems while testing. Therefore I added a check, if(TIME_FOR_AUTH > 0) ...
to my code.
Now I get the described warning. Since IntelliJ always asks me to delete this construct (and I'm not alone in this project), I wanted to know if there is a common practice doing that in Java / some possibility to suppress the warning.