code: public static boolean isValid(Range range) {
          if (range == null) {
              return false;
          }
          
          double min = range.getMinimum().doubleValue();
          double max = range.getMaximum().doubleValue();
          
          return min != max && !Double.isNaN(min) && !Double.isInfinite(min) &&
                  !Double.isNaN(max) && !Double.isInfinite(max);
      }
docs: Checks whether the range is of non-zero size and the boundaries are
  neither NaN or Infinity.
  
  @param range the range
  @return true if range is of finite, non-zero size