Class NumericFunctions

Object
NumericFunctions

@PublicApi public final class NumericFunctions extends Object
Helper methods for using numeric functions.
  • Constructor Details

    • NumericFunctions

      public NumericFunctions()
  • Method Details

    • longOrZero

      public static long longOrZero(Number number)
      Parameters:
      number - a number
      Returns:
      The given number's long value, 0L if null
    • longOrZero

      public static <T> long longOrZero(T argument, Function<? super T,? extends Number> function)
      Parameters:
      argument - an argument
      function - a numeric function
      Returns:
      The given function's long value for the argument, 0L if anything is null
    • longOrNull

      @Nullable public static Long longOrNull(Number number)
      Parameters:
      number - a number
      Returns:
      A Long with the given number's long value, null if number is null
    • longOrNull

      @Nullable public static <T> Long longOrNull(T argument, Function<? super T,? extends Number> function)
      Parameters:
      argument - an argument
      function - a numeric function
      Returns:
      A Long with the given function's long value for the argument, null if anything is null
    • nonNegativeLong

      public static long nonNegativeLong(Number number)
      Parameters:
      number - a number
      Returns:
      The given number's long value, 0L if null or negative
    • nonNegativeLong

      public static <T> long nonNegativeLong(T argument, Function<? super T,? extends Number> function)
      Parameters:
      argument - an argument
      function - a numeric function
      Returns:
      The given function's long value for the argument, 0L if anything is null or negative
    • doubleOrZero

      public static double doubleOrZero(Number number)
      Parameters:
      number - a number
      Returns:
      The given number's double value, 0.0 if null
    • doubleOrZero

      public static <T> double doubleOrZero(T argument, Function<? super T,? extends Number> function)
      Parameters:
      argument - an argument
      function - a numeric function
      Returns:
      The given function's double value for the argument, 0.0 if anything is null
    • doubleOrNull

      @Nullable public static Double doubleOrNull(Number number)
      Parameters:
      number - a number
      Returns:
      A Double with the given number's double value, null if number is null
    • doubleOrNull

      @Nullable public static <T> Double doubleOrNull(T argument, Function<? super T,? extends Number> function)
      Parameters:
      argument - an argument
      function - a numeric function
      Returns:
      A Double with the given function's double value for the argument, null if anything is null
    • nonNegativeDouble

      public static double nonNegativeDouble(Number number)
      Parameters:
      number - a number
      Returns:
      The given number's double value, 0.0 if null or negative
    • nonNegativeDouble

      public static <T> double nonNegativeDouble(T argument, Function<? super T,? extends Number> function)
      Parameters:
      argument - an argument
      function - a numeric function
      Returns:
      The given function's double value for the argument, 0.0 if anything is null or negative
    • nonNegativeDoubleAddOrNull

      public static Double nonNegativeDoubleAddOrNull(Number a, Number b)
      Appends two numbers as double's with tracking of nulls and clipping to zero. Axioms: null + a == a, a + null == a, a + b == a + b, null + null == null
      Parameters:
      a - first operand
      b - second operand
      Returns:
      a + b or null
    • longAddOrNull

      public static Long longAddOrNull(Number a, Number b)
      Appends two numbers as long's with tracking of nulls Axioms: null + a == a, a + null == a, a + b == a + b, null + null == null
      Parameters:
      a - first operand
      b - second operand
      Returns:
      a + b or null
    • longAddOrNull

      public static long longAddOrNull(long a, Long b)
    • equals

      public static boolean equals(Number a, Number b)