Class UnsignedRangeCheck

java.lang.Object
com.io7m.junsigned.ranges.UnsignedRangeCheck

public final class UnsignedRangeCheck 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:
  • RangeCheckException
  • 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).

      The values in question are assumed to be unsigned when performing the comparison.

      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).

      The values in question are assumed to be unsigned when performing the comparison.

      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
    • 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).

      The values in question are assumed to be unsigned when performing the comparison.

      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).

      The values in question are assumed to be unsigned when performing the comparison.

      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
    • 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).

      The values in question are assumed to be unsigned when performing the comparison.

      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
    • 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).

      The values in question are assumed to be unsigned when performing the comparison.

      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
    • 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).

      The values in question are assumed to be unsigned when performing the comparison.

      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
    • 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).

      The values in question are assumed to be unsigned when performing the comparison.

      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
    • checkIncludedInLong

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

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

      The values in question are assumed to be unsigned when performing the comparison.

      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
    • checkIncludedInInteger

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

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

      The values in question are assumed to be unsigned when performing the comparison.

      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
    • checkRangeIncludedInLong

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

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

      The values in question are assumed to be unsigned when performing the comparison.

      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
    • checkRangeIncludedInInteger

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

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

      The values in question are assumed to be unsigned when performing the comparison.

      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