Class NumberUtils

java.lang.Object
org.checkerframework.common.value.util.NumberUtils

public class NumberUtils extends Object
Utility routines for manipulating numbers.
  • Method Details

    • castNumbers

      public static List<? extends Number> castNumbers(TypeMirror type, List<? extends Number> numbers)
      Converts a List<A> to a List<B>, where A and B are numeric types.
      Parameters:
      type - the type to cast to
      numbers - the numbers to cast to the given type
      Returns:
      a list of numbers of the given type
    • castRange

      public static Range castRange(TypeMirror type, Range range)
      Return a range that restricts the given range to the given type. That is, return the range resulting from casting a value with the given range.
      Parameters:
      type - the type for the cast; the result will be within it
      range - the original range; the result will be within it
      Returns:
      the intersection of the given range and the possible values of the given type