We know assertion usually disabled before deploy time, if we use it like this, could be not good for production running:
Do Use Assertions, Even in Public Methods, to Check for Cases
that You Know Are Never, Ever Supposed to Happen
This can include code blocks that should never be reached, including the default of a switch statement as follows:
switch(x) {
case 1: y = 3;
case 2: y = 9;
case 3: y = 27;
default: assert false; // We're never supposed to get here!
}
If you assume that a particular code block won't be reached, as in the preceding example where you assert that x must be either 2, 3, or 4, then you can use assert false to cause an AssertionError to be thrown immediately if you ever do reach that code.