Class RangeCheck

java.lang.Object
com.io7m.jranges.RangeCheck

public final class RangeCheck extends Object

Functions for enforcing range constraints at run time.

The functions are intended for use in the manner of assertions. That is, the program should behave identically if all of the checks are removed. The functions raise RangeCheckException upon failure. Exceptions of this type are not intended to be caught and handled; they indicate program bugs.

See Also:
  • Method Details

    • checkGreaterLong

      public static long checkGreaterLong(long x, String x_name, long in_lower, String lower_name)

      Assert that x (named x_name) is greater than in_lower (named lower_name).

      Parameters:
      x - The checked value
      in_lower - The lower bound
      x_name - The name of the checked value
      lower_name - The name of the lower bound
      Returns:
      x
      Since:
      2.0.0
    • checkGreaterInteger

      public static int checkGreaterInteger(int x, String x_name, int in_lower, String lower_name)

      Assert that x (named x_name) is greater than in_lower (named lower_name).

      Parameters:
      x - The checked value
      in_lower - The lower bound
      x_name - The name of the checked value
      lower_name - The name of the lower bound
      Returns:
      x
      Since:
      2.0.0
    • checkGreaterBig

      public static BigInteger checkGreaterBig(BigInteger x, String x_name, BigInteger in_lower, String lower_name)

      Assert that x (named x_name) is greater than in_lower (named lower_name).

      Parameters:
      x - The checked value
      in_lower - The lower bound
      x_name - The name of the checked value
      lower_name - The name of the lower bound
      Returns:
      x
    • checkGreaterDouble

      public static double checkGreaterDouble(double x, String x_name, double in_lower, String lower_name)

      Assert that x (named x_name) is greater than in_lower (named lower_name).

      Parameters:
      x - The checked value
      in_lower - The lower bound
      x_name - The name of the checked value
      lower_name - The name of the lower bound
      Returns:
      x
    • checkGreaterEqualLong

      public static long checkGreaterEqualLong(long x, String x_name, long in_lower, String lower_name)

      Assert that x (named x_name) is greater than or equal to in_lower (named lower_name).

      Parameters:
      x - The checked value
      in_lower - The lower bound
      x_name - The name of x
      lower_name - The name of the lower bound
      Returns:
      x
      Since:
      2.0.0
    • checkGreaterEqualInteger

      public static int checkGreaterEqualInteger(int x, String x_name, int in_lower, String lower_name)

      Assert that x (named x_name) is greater than or equal to in_lower (named lower_name).

      Parameters:
      x - The checked value
      in_lower - The lower bound
      x_name - The name of x
      lower_name - The name of the lower bound
      Returns:
      x
      Since:
      2.0.0
    • checkGreaterEqualBig

      public static BigInteger checkGreaterEqualBig(BigInteger x, String x_name, BigInteger in_lower, String lower_name)

      Assert that x (named x_name) is greater than or equal to in_lower (named lower_name).

      Parameters:
      x - The checked value
      in_lower - The lower bound
      x_name - The name of the checked value
      lower_name - The name of the lower bound
      Returns:
      x
    • checkGreaterEqualDouble

      public static double checkGreaterEqualDouble(double x, String x_name, double in_lower, String lower_name)

      Assert that x (named x_name) is greater than or equal to in_lower (named lower_name).

      Parameters:
      x - The checked value
      in_lower - The lower bound
      x_name - The name of x
      lower_name - The name of the lower bound
      Returns:
      x
    • checkIncludedInLong

      public static long checkIncludedInLong(long x, String x_name, RangeInclusiveL range, String range_name)

      Assert that x (named x_name) is included in the given range range (named range_name).

      Parameters:
      x - The checked value
      x_name - The name of the checked value
      range - The inclusive range
      range_name - The name of the inclusive range
      Returns:
      x
      Since:
      2.0.0
    • checkIncludedInInteger

      public static int checkIncludedInInteger(int x, String x_name, RangeInclusiveI range, String range_name)

      Assert that x (named x_name) is included in the given range range (named range_name).

      Parameters:
      x - The checked value
      x_name - The name of the checked value
      range - The inclusive range
      range_name - The name of the inclusive range
      Returns:
      x
      Since:
      2.0.0
    • checkIncludedInBig

      public static BigInteger checkIncludedInBig(BigInteger x, String x_name, RangeInclusiveB range, String range_name)

      Assert that x (named x_name) is included in the given range range (named range_name).

      Parameters:
      x - The checked value
      x_name - The name of the checked value
      range - The inclusive range
      range_name - The name of the inclusive range
      Returns:
      x
    • checkLessLong

      public static long checkLessLong(long x, String x_name, long in_upper, String upper_name)

      Assert that x (named x_name) is less than in_upper (named upper_name).

      Parameters:
      x - The checked value
      in_upper - The upper bound
      x_name - The name of the checked value
      upper_name - The name of the upper bound
      Returns:
      x
      Since:
      2.0.0
    • checkLessInteger

      public static int checkLessInteger(int x, String x_name, int in_upper, String upper_name)

      Assert that x (named x_name) is less than in_upper (named upper_name).

      Parameters:
      x - The checked value
      in_upper - The upper bound
      x_name - The name of the checked value
      upper_name - The name of the upper bound
      Returns:
      x
      Since:
      2.0.0
    • checkLessBig

      public static BigInteger checkLessBig(BigInteger x, String x_name, BigInteger in_upper, String upper_name)

      Assert that x (named x_name) is less than in_upper (named upper_name).

      Parameters:
      x - The checked value
      in_upper - The upper bound
      x_name - The name of the checked value
      upper_name - The name of the upper bound
      Returns:
      x
    • checkLessDouble

      public static double checkLessDouble(double x, String x_name, double in_upper, String upper_name)

      Assert that x (named x_name) is less than in_upper (named upper_name).

      Parameters:
      x - The checked value
      in_upper - The upper bound
      x_name - The name of the checked value
      upper_name - The name of the upper bound
      Returns:
      x
    • checkLessEqualLong

      public static long checkLessEqualLong(long x, String x_name, long in_upper, String upper_name)

      Assert that x (named x_name) is less than or equal to in_upper (named upper_name).

      Parameters:
      x - The checked value
      in_upper - The upper bound
      x_name - The name of x
      upper_name - The name of the upper bound
      Returns:
      x
      Since:
      2.0.0
    • checkLessEqualInteger

      public static int checkLessEqualInteger(int x, String x_name, int in_upper, String upper_name)

      Assert that x (named x_name) is less than or equal to in_upper (named upper_name).

      Parameters:
      x - The checked value
      in_upper - The upper bound
      x_name - The name of x
      upper_name - The name of the upper bound
      Returns:
      x
      Since:
      2.0.0
    • checkLessEqualBig

      public static BigInteger checkLessEqualBig(BigInteger x, String x_name, BigInteger in_upper, String upper_name)

      Assert that x (named x_name) is less than or equal to in_upper (named upper_name).

      Parameters:
      x - The checked value
      in_upper - The upper bound
      x_name - The name of the checked value
      upper_name - The name of the upper bound
      Returns:
      x
    • checkLessEqualDouble

      public static double checkLessEqualDouble(double x, String x_name, double in_upper, String upper_name)

      Assert that x (named x_name) is less than or equal to in_upper (named upper_name).

      Parameters:
      x - The checked value
      in_upper - The upper bound
      x_name - The name of x
      upper_name - The name of the upper bound
      Returns:
      x
    • checkRangeIncludedInLong

      public static RangeInclusiveL checkRangeIncludedInLong(RangeInclusiveL inner, String inner_name, RangeInclusiveL outer, String outer_name)

      Assert that inner (named inner_name) is included in the given range outer (named outer_name).

      Parameters:
      inner - The checked range
      inner_name - The name of the checked range
      outer - The outer range
      outer_name - The name of the outer range
      Returns:
      inner
      Since:
      2.0.0
    • checkRangeIncludedInInteger

      public static RangeInclusiveI checkRangeIncludedInInteger(RangeInclusiveI inner, String inner_name, RangeInclusiveI outer, String outer_name)

      Assert that inner (named inner_name) is included in the given range outer (named outer_name).

      Parameters:
      inner - The checked range
      inner_name - The name of the checked range
      outer - The outer range
      outer_name - The name of the outer range
      Returns:
      inner
      Since:
      2.0.0
    • checkRangeIncludedInBig

      public static RangeInclusiveB checkRangeIncludedInBig(RangeInclusiveB inner, String inner_name, RangeInclusiveB outer, String outer_name)

      Assert that inner (named inner_name) is included in the given range outer (named outer_name).

      Parameters:
      inner - The checked range
      inner_name - The name of the checked range
      outer - The outer range
      outer_name - The name of the outer range
      Returns:
      inner