Class NumberUtils


  • public class NumberUtils
    extends java.lang.Object
    Utility routines for manipulating numbers.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static @Nullable java.util.List<? extends java.lang.Number> castNumbers​(javax.lang.model.type.TypeMirror type, boolean isUnsigned, java.util.List<? extends java.lang.Number> numbers)
      Converts a List<A> to a List<B>, where A and B are numeric types.
      static java.util.List<? extends java.lang.Number> castNumbers​(javax.lang.model.type.TypeMirror type, java.util.List<? extends java.lang.Number> numbers)
      Converts a List<A> to a List<B>, where A and B are numeric types.
      static Range castRange​(javax.lang.model.type.TypeMirror type, Range range)
      Return a range that restricts the given range to the given type.
      • Methods inherited from class java.lang.Object

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

      • castNumbers

        public static java.util.List<? extends java.lang.Number> castNumbers​(javax.lang.model.type.TypeMirror type,
                                                                             java.util.List<? extends java.lang.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
      • castNumbers

        public static @Nullable java.util.List<? extends java.lang.Number> castNumbers​(javax.lang.model.type.TypeMirror type,
                                                                                       boolean isUnsigned,
                                                                                       java.util.List<? extends java.lang.Number> numbers)
        Converts a List<A> to a List<B>, where A and B are numeric types.
        Parameters:
        type - the type to cast to
        isUnsigned - if true, treat type as unsigned
        numbers - the numbers to cast to the given type
        Returns:
        a list of numbers of the given type
      • castRange

        public static Range castRange​(javax.lang.model.type.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