Class RangeCheck


  • public final class RangeCheck
    extends java.lang.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:
    RangeCheckException
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.math.BigInteger checkGreaterBig​(java.math.BigInteger x, java.lang.String x_name, java.math.BigInteger in_lower, java.lang.String lower_name)
      Assert that x (named x_name) is greater than in_lower (named lower_name).
      static double checkGreaterDouble​(double x, java.lang.String x_name, double in_lower, java.lang.String lower_name)
      Assert that x (named x_name) is greater than in_lower (named lower_name).
      static java.math.BigInteger checkGreaterEqualBig​(java.math.BigInteger x, java.lang.String x_name, java.math.BigInteger in_lower, java.lang.String lower_name)
      Assert that x (named x_name) is greater than or equal to in_lower (named lower_name).
      static double checkGreaterEqualDouble​(double x, java.lang.String x_name, double in_lower, java.lang.String lower_name)
      Assert that x (named x_name) is greater than or equal to in_lower (named lower_name).
      static int checkGreaterEqualInteger​(int x, java.lang.String x_name, int in_lower, java.lang.String lower_name)
      Assert that x (named x_name) is greater than or equal to in_lower (named lower_name).
      static long checkGreaterEqualLong​(long x, java.lang.String x_name, long in_lower, java.lang.String lower_name)
      Assert that x (named x_name) is greater than or equal to in_lower (named lower_name).
      static int checkGreaterInteger​(int x, java.lang.String x_name, int in_lower, java.lang.String lower_name)
      Assert that x (named x_name) is greater than in_lower (named lower_name).
      static long checkGreaterLong​(long x, java.lang.String x_name, long in_lower, java.lang.String lower_name)
      Assert that x (named x_name) is greater than in_lower (named lower_name).
      static java.math.BigInteger checkIncludedInBig​(java.math.BigInteger x, java.lang.String x_name, RangeInclusiveB range, java.lang.String range_name)
      Assert that x (named x_name) is included in the given range range (named range_name).
      static int checkIncludedInInteger​(int x, java.lang.String x_name, RangeInclusiveI range, java.lang.String range_name)
      Assert that x (named x_name) is included in the given range range (named range_name).
      static long checkIncludedInLong​(long x, java.lang.String x_name, RangeInclusiveL range, java.lang.String range_name)
      Assert that x (named x_name) is included in the given range range (named range_name).
      static java.math.BigInteger checkLessBig​(java.math.BigInteger x, java.lang.String x_name, java.math.BigInteger in_upper, java.lang.String upper_name)
      Assert that x (named x_name) is less than in_upper (named upper_name).
      static double checkLessDouble​(double x, java.lang.String x_name, double in_upper, java.lang.String upper_name)
      Assert that x (named x_name) is less than in_upper (named upper_name).
      static java.math.BigInteger checkLessEqualBig​(java.math.BigInteger x, java.lang.String x_name, java.math.BigInteger in_upper, java.lang.String upper_name)
      Assert that x (named x_name) is less than or equal to in_upper (named upper_name).
      static double checkLessEqualDouble​(double x, java.lang.String x_name, double in_upper, java.lang.String upper_name)
      Assert that x (named x_name) is less than or equal to in_upper (named upper_name).
      static int checkLessEqualInteger​(int x, java.lang.String x_name, int in_upper, java.lang.String upper_name)
      Assert that x (named x_name) is less than or equal to in_upper (named upper_name).
      static long checkLessEqualLong​(long x, java.lang.String x_name, long in_upper, java.lang.String upper_name)
      Assert that x (named x_name) is less than or equal to in_upper (named upper_name).
      static int checkLessInteger​(int x, java.lang.String x_name, int in_upper, java.lang.String upper_name)
      Assert that x (named x_name) is less than in_upper (named upper_name).
      static long checkLessLong​(long x, java.lang.String x_name, long in_upper, java.lang.String upper_name)
      Assert that x (named x_name) is less than in_upper (named upper_name).
      static RangeInclusiveB checkRangeIncludedInBig​(RangeInclusiveB inner, java.lang.String inner_name, RangeInclusiveB outer, java.lang.String outer_name)
      Assert that inner (named inner_name) is included in the given range outer (named outer_name).
      static RangeInclusiveI checkRangeIncludedInInteger​(RangeInclusiveI inner, java.lang.String inner_name, RangeInclusiveI outer, java.lang.String outer_name)
      Assert that inner (named inner_name) is included in the given range outer (named outer_name).
      static RangeInclusiveL checkRangeIncludedInLong​(RangeInclusiveL inner, java.lang.String inner_name, RangeInclusiveL outer, java.lang.String outer_name)
      Assert that inner (named inner_name) is included in the given range outer (named outer_name).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • checkGreaterLong

        public static long checkGreaterLong​(long x,
                                            java.lang.String x_name,
                                            long in_lower,
                                            java.lang.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,
                                              java.lang.String x_name,
                                              int in_lower,
                                              java.lang.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 java.math.BigInteger checkGreaterBig​(java.math.BigInteger x,
                                                           java.lang.String x_name,
                                                           java.math.BigInteger in_lower,
                                                           java.lang.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,
                                                java.lang.String x_name,
                                                double in_lower,
                                                java.lang.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,
                                                 java.lang.String x_name,
                                                 long in_lower,
                                                 java.lang.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,
                                                   java.lang.String x_name,
                                                   int in_lower,
                                                   java.lang.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 java.math.BigInteger checkGreaterEqualBig​(java.math.BigInteger x,
                                                                java.lang.String x_name,
                                                                java.math.BigInteger in_lower,
                                                                java.lang.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,
                                                     java.lang.String x_name,
                                                     double in_lower,
                                                     java.lang.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,
                                               java.lang.String x_name,
                                               RangeInclusiveL range,
                                               java.lang.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,
                                                 java.lang.String x_name,
                                                 RangeInclusiveI range,
                                                 java.lang.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 java.math.BigInteger checkIncludedInBig​(java.math.BigInteger x,
                                                              java.lang.String x_name,
                                                              RangeInclusiveB range,
                                                              java.lang.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,
                                         java.lang.String x_name,
                                         long in_upper,
                                         java.lang.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,
                                           java.lang.String x_name,
                                           int in_upper,
                                           java.lang.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 java.math.BigInteger checkLessBig​(java.math.BigInteger x,
                                                        java.lang.String x_name,
                                                        java.math.BigInteger in_upper,
                                                        java.lang.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,
                                             java.lang.String x_name,
                                             double in_upper,
                                             java.lang.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,
                                              java.lang.String x_name,
                                              long in_upper,
                                              java.lang.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,
                                                java.lang.String x_name,
                                                int in_upper,
                                                java.lang.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 java.math.BigInteger checkLessEqualBig​(java.math.BigInteger x,
                                                             java.lang.String x_name,
                                                             java.math.BigInteger in_upper,
                                                             java.lang.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,
                                                  java.lang.String x_name,
                                                  double in_upper,
                                                  java.lang.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,
                                                               java.lang.String inner_name,
                                                               RangeInclusiveL outer,
                                                               java.lang.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,
                                                                  java.lang.String inner_name,
                                                                  RangeInclusiveI outer,
                                                                  java.lang.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,
                                                              java.lang.String inner_name,
                                                              RangeInclusiveB outer,
                                                              java.lang.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