Class NumberUtils

java.lang.Object
io.servicetalk.utils.internal.NumberUtils

public final class NumberUtils extends Object
Helper utilities for Numbers.
  • Method Details

    • ensurePositive

      public static int ensurePositive(int value, String name)
      Ensures the int is positive, excluding zero.
      Parameters:
      value - the int value to validate
      name - name of the variable
      Returns:
      the passed value if all checks pass
      Throws:
      IllegalArgumentException - if the passed int is not greater than zero
    • ensurePositive

      public static long ensurePositive(long value, String name)
      Ensures the long is positive, excluding zero.
      Parameters:
      value - the long value to validate
      name - name of the variable
      Returns:
      the passed value if all checks pass
      Throws:
      IllegalArgumentException - if the passed long is not greater than zero
    • ensureNonNegative

      public static int ensureNonNegative(int value, String name)
      Ensures the int is non-negative.
      Parameters:
      value - the int value to validate
      name - name of the variable
      Returns:
      the passed value if all checks pass
      Throws:
      IllegalArgumentException - if the passed int is less than zero
    • ensureNonNegative

      public static long ensureNonNegative(long value, String name)
      Ensures the long is non-negative.
      Parameters:
      value - the long value to validate
      name - name of the variable
      Returns:
      the passed value if all checks pass
      Throws:
      IllegalArgumentException - if the passed long is less than zero