@SuppressWarnings({ "rawtypes", "unchecked" })
  public static <V> void checkRange(V value, V minimum, V maximum, Object valueSource) throws ValueOutOfRangeException {

    Objects.requireNonNull(value, "value");
    Comparator comparator;
    if (value instanceof Comparable) {
      comparator = ComparableComparator.getInstance();
    } else if (value instanceof Number) {
      comparator = NumberComparator.getInstance();
    } else {
      throw new IllegalArgumentException(value.getClass().getName());
    }
    boolean valid = true;
    int delta;
    if (minimum != null) {
      delta = comparator.compare(value, minimum);
      if (delta < 0) {
        // value < min
        valid = false;
      }
    }
    if (maximum != null) {
      delta = comparator.compare(value, maximum);
      if (delta > 0) {
        // value > max
        valid = false;
      }
    }
    if (!valid) {
      throw new ValueOutOfRangeException(value, minimum, maximum, valueSource);
    }
  }
@ SuppressWarnings ( { "rawtypes" , "unchecked" } ) public static < V > void checkRange ( V value , V minimum , V maximum , Object valueSource ) throws ValueOutOfRangeException { Objects . requireNonNull ( value , "value" ) ; Comparator comparator ; if ( value instanceof Comparable ) { comparator = ComparableComparator . getInstance ( ) ; } else if ( value instanceof Number ) { comparator = NumberComparator . getInstance ( ) ; } else { throw new IllegalArgumentException ( value . getClass ( ) . getName ( ) ) ; } boolean valid = true ; int delta ; if ( minimum != null ) { delta = comparator . compare ( value , minimum ) ; if ( delta < 0 ) { valid = false ; } } if ( maximum != null ) { delta = comparator . compare ( value , maximum ) ; if ( delta > 0 ) { valid = false ; } } if ( ! valid ) { throw new ValueOutOfRangeException ( value , minimum , maximum , valueSource ) ; } }
This method checks that the given {@code value} is in the inclusive range from {@code minimum} to
{@code maximum}.

@param <V> the generic type of the {@code value} to check.

@param value is the value to check.
@param minimum is the minimum number allowed.
@param maximum is the maximum number allowed.
@param valueSource describes the source of the value. This may be the filename where the value was read
from, an XPath where the value was located in an XML document, etc. It is used in exceptions
thrown if something goes wrong. This will help to find the problem easier. It may be {@code null}
if there is no helpful source available.
@throws ValueOutOfRangeException - if the given {@code value} is NOT in the range from {@code minimum} to
{@code maximum}.
@since 7.1.0