public static int checkArgumentInRange(int value, int lower, int upper,
                                           String valueName) {
        if (value < lower) {
            throw new IllegalArgumentException(
                    String.format(
                            "%s is out of range of [%d, %d] (too low)", valueName, lower, upper));
        } else if (value > upper) {
            throw new IllegalArgumentException(
                    String.format(
                            "%s is out of range of [%d, %d] (too high)", valueName, lower, upper));
        }

        return value;
    }
Ensures that the argument int value is within the inclusive range.

@param value     a int value
@param lower     the lower endpoint of the inclusive range
@param upper     the upper endpoint of the inclusive range
@param valueName the name of the argument to use if the check fails
@return the validated int value
@throws IllegalArgumentException if {@code value} was not within the range
android/android_framework/base/src/main/java/github/tornaco/android/thanos/core/util/Preconditions.java