List of utility methods to do Number Range Check
int | inRange(final int value, final int min, final int max) in Range return Math.max(Math.min(value, max), min);
|
int | inRange(final int value, final int min, final int max, final String fieldName) Verifies the value and fails if the given value is outside the given range. if (value < min || value > max) { throw new IllegalArgumentException( "The " + fieldName + " value of " + value + " is out of range: [" + min + "," + max + "]."); return value; |
boolean | inRange(float n, float min, float max) Checks if x is inclusively within the specified range. return ((n >= min) && (n < max));
|
boolean | inrange(int actual, int leftRange, int rightRange) inrange return (actual >= leftRange && actual <= rightRange);
|
boolean | inRange(int check, int range) in Range double from = range - (range * 5 / 100); double to = range + (range * 5 / 100); return from <= check && check <= to; |
int | inRange(int checkValue, int min, int max) in Range if (checkValue < min) { return min; if (checkValue > max) { return max; return checkValue; |
boolean | inRange(int firstIndex, int secondIndex) Check whether the first index is in range of the second one. if (firstIndex < 34 && secondIndex < 34) { if (Math.abs(secondIndex - firstIndex) <= 6.0) { return true; } else { return false; if (firstIndex > 33) { ... |
boolean | inRange(int l, int u, int v, int... v_) in Range boolean r = v >= l && v <= u; if (!r) return false; for (int v__ : v_) if (!(r &= (v__ >= l && v__ <= u))) return false; return true; |
boolean | inRange(int minValue, int maxValue, int value) in Range if (maxValue < minValue) { return false; return (value >= minValue) && (value <= maxValue); |
int | inRange(int n, int lo, int hi) Avoid a number getting out of a certain range return n < lo ? lo : (n > hi ? hi : n);
|