Class NumberUtils
- java.lang.Object
-
- org.checkerframework.common.value.util.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 aList<A>
to aList<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 aList<A>
to aList<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.
-
-
-
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 aList<A>
to aList<B>
, where A and B are numeric types.- Parameters:
type
- the type to cast tonumbers
- 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 aList<A>
to aList<B>
, where A and B are numeric types.- Parameters:
type
- the type to cast toisUnsigned
- if true, treattype
as unsignednumbers
- 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 itrange
- the original range; the result will be within it- Returns:
- the intersection of the given range and the possible values of the given type
-
-