Your problem is with short-circuiting. Using ||
causes the operation to short-circuit once one true value is found. You can instead use |
to evaluate both expressions, even if the first is true. Same is true with &&
and &
when it comes to evaluating to false.
if (true || someMethod()) { }
In this statement above, the someMethod() will never be called because true
short-circuits the result.
if (true | someMethod()) { }
In this, the someMethod() will be called even though it being true or false is irrelevant to the evaluation of the boolean expression as a whole. See here for more information on short-circuiting in Java: Java logical operator short-circuiting