Java Utililty Methods Number Between

List of utility methods to do Number Between

Description

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

Method

booleanbetween(Comparable obj, Comparable from, Comparable to)
Checks if the given object is between the last two parameter values.
int compareObjFrom = compare(obj, from);
int compareObjTo = compare(obj, to);
return (compareObjFrom >= 0) && (compareObjTo <= 0);
Tbetween(T lower, T upper, T value)
Returns a value which is within the lower and upper borders.
return (lower.compareTo(value) < 0) ? lower : ((upper.compareTo(value) > 0) ? upper : value);
booleanbetween(T subject, T lower, T upper, boolean exclLowerEnd, boolean exclUpperEnd)
between
if (subject == null)
    return false;
boolean validExclEnds = (lower == null ? true : lower.compareTo(subject) < 0)
        && (upper == null ? true : upper.compareTo(subject) > 0);
return validExclEnds || (!exclLowerEnd && subject.equals(lower))
        || (!exclUpperEnd && subject.equals(upper));