Java Utililty Methods Number Range Check

List of utility methods to do Number Range Check

Description

The list of methods to do Number Range Check are organized into topic(s).

Method

booleaninRange(int num, int from, int to, int flag)
in Range
return ((flag & MASK_LEFT_BOUND) == 0 ? num > from : num >= from)
        && ((flag & MASK_RIGHT_BOUND) == 0 ? num < to : num <= to);
booleaninRange(int value, int lowerBound, int upperBound)
in Range
return (lowerBound <= value && value <= upperBound);
intinRange(int value, int min, int max)
Return the value v if min <= v <= max, otherwise throw an exception
if (value < min)
    throw new IllegalArgumentException("The value " + value + " is lower than the minimum value of " + min);
else if (value > max)
    throw new IllegalArgumentException(
            "The value " + value + " is greater than the maximum value of " + max);
else
    return value;
booleaninRange(int value, int min, int max)
inRange checks if a value is between two other values
if (value < min) {
    return false;
if (value > max) {
    return false;
return true;
intinRange(int value, int min, int max)
Brings an integer into a specified range.
return value < min ? min : value > max ? max : value;
booleaninRange(int value, int min, int max)
checks if a value is in the range min..max, min+max are included
return (value >= min && value <= max);
booleaninRange(int x, int a, int b)
in Range
return x >= a && x <= b;
BooleaninRange(Integer x1, Integer y1, Integer x2, Integer y2)
in Range
if (Math.abs(x1 - x2) > 60 || (Math.abs(y1 - y2)) > 60) {
    return false;
} else {
    return true;
booleaninRange(long value, long lowerBound, long upperBound)
Validates whether a given value falls inside the given range.
return ((value >= lowerBound) && (value <= upperBound));
booleaninrange2(double value, double min, double max)
checks if value is between min and max, inclusive.
if (max < min) {
    double t = min;
    min = max;
    max = t;
return value <= max && value >= min;