Java Number Range Check rangeCheck(final C start, final C end, final C step)

Here you can find the source of rangeCheck(final C start, final C end, final C step)

Description

range Check

License

Open Source License

Declaration

static <C extends Number & Comparable<C>> void rangeCheck(final C start, final C end, final C step) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    static <C extends Number & Comparable<C>> void rangeCheck(final C start, final C end, final C step) {
        if (step.doubleValue() == 0) {
            throw new IllegalArgumentException("step is 0.");
        }/*w w w  .j a v  a  2  s.  co  m*/
        if (start.compareTo(end) < 0 && step.doubleValue() < 0) {
            throw new IllegalArgumentException("start < end, but step is negative");
        }
    }
}

Related

  1. inRange(int x, int a, int b)
  2. inRange(Integer x1, Integer y1, Integer x2, Integer y2)
  3. inRange(long value, long lowerBound, long upperBound)
  4. inrange2(double value, double min, double max)
  5. rangeCheck(double value)
  6. rangeCheck(final int value, final int min, final int max)
  7. rangeCheck(int arrayLen, int fromIndex, int toIndex)
  8. rangeCheck(int arrayLength, int offset, int length)
  9. rangeCheck(int index, int size)