code: private static <T extends Comparable<T>> void ensureValidRange(T min, T max) {
      if (min == null) {
        throw new InvalidOperationException("Null value for minimum.");
      }
      if (max == null) {
        throw new InvalidOperationException("Null value for maximum.");
      }
      if (min.compareTo(max) >= 0) {
        throw new InvalidOperationException("Invalid range: " + min + " >= " + max);
      }
    }
docs: Range validation utility method.
  @param <T> Type of data.
  @param min Minimum value.
  @param max Maximum value.
  @throws InvalidOperationException if the range is not valid.