public static float[] checkArrayElementsInRange(float[] value, float lower, float upper,
                                                    String valueName) {
        checkNotNull(value, valueName + " must not be null");

        for (int i = 0; i < value.length; ++i) {
            float v = value[i];

            if (Float.isNaN(v)) {
                throw new IllegalArgumentException(valueName + "[" + i + "] must not be NaN");
            } else if (v < lower) {
                throw new IllegalArgumentException(
                        String.format("%s[%d] is out of range of [%f, %f] (too low)",
                                valueName, i, lower, upper));
            } else if (v > upper) {
                throw new IllegalArgumentException(
                        String.format("%s[%d] is out of range of [%f, %f] (too high)",
                                valueName, i, lower, upper));
            }
        }

        return value;
    }
Ensures that all elements in the argument floating point array are within the inclusive range
While this can be used to range check against +/- infinity, note that all NaN numbers
will always be out of range.

@param value     a floating point array of values
@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 floating point value
@throws IllegalArgumentException if any of the elements in {@code value} were out of range
@throws NullPointerException     if the {@code value} was {@code null}
android/android_framework/base/src/main/java/util/PreconditionUtils.java