Package com.atlassian.bamboo.util
Class NumberUtils
- java.lang.Object
-
- com.atlassian.bamboo.util.NumberUtils
-
public class NumberUtils extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static void
arrayStore(int number, @org.jetbrains.annotations.NotNull byte[] array, int startIndex)
static void
arrayStore(long number, @org.jetbrains.annotations.NotNull byte[] array, int startIndex)
static @Nullable Double
createDoubleQuietly(@Nullable String s)
seeNumberUtils.createDouble(String)
.static NumberUtils
getInstance()
static boolean
isPositiveInteger(@Nullable String input)
static int
max(int a, int b)
static <T extends Comparable<? super T>>
Tmax(@NotNull Collection<T> collection)
static int
min(int a, int b)
static String
padWithZeroes(Number value, int numberOfZeroes)
static long
randomNonNegativeLong()
static double
round(double val, int places)
static float
round(float val, int places)
static double
stringToDouble(String s)
Deprecated.since 4.2 consider usingcreateDoubleQuietly(String)
static int
stringToInt(String s)
static long
stringToLong(String s)
static @Nullable Integer
toInteger(@Nullable Number number)
static double
unlocalizedStringToDouble(@Nullable String s)
Convert string to double value.static long
valueOf(Long l, long defaultValue)
Null-safe unboxing of Long
-
-
-
Method Detail
-
getInstance
public static NumberUtils getInstance()
-
randomNonNegativeLong
public static long randomNonNegativeLong()
-
min
public static int min(int a, int b)
-
max
public static int max(int a, int b)
-
round
public static double round(double val, int places)
-
round
public static float round(float val, int places)
-
stringToDouble
@Deprecated public static double stringToDouble(String s)
Deprecated.since 4.2 consider usingcreateDoubleQuietly(String)
- Returns:
-
createDoubleQuietly
@Nullable public static @Nullable Double createDoubleQuietly(@Nullable @Nullable String s)
seeNumberUtils.createDouble(String)
. Returns null instead of throwing an exception.
-
unlocalizedStringToDouble
public static double unlocalizedStringToDouble(@Nullable @Nullable String s)
Convert string to double value. Method expects non-localized input (as produced byDouble.toString(double)
). If the input cannot be parsed method would log this and return 0. This method is intended to be used from FreeMarker code.- Parameters:
s
- input string containing representation of a double value.- Returns:
- parsed value or 0 if there was error during parsing
-
stringToLong
public static long stringToLong(String s)
-
stringToInt
public static int stringToInt(String s)
-
max
public static <T extends Comparable<? super T>> T max(@NotNull @NotNull Collection<T> collection)
-
isPositiveInteger
public static boolean isPositiveInteger(@Nullable @Nullable String input)
-
arrayStore
public static void arrayStore(int number, @NotNull @org.jetbrains.annotations.NotNull byte[] array, int startIndex)
-
arrayStore
public static void arrayStore(long number, @NotNull @org.jetbrains.annotations.NotNull byte[] array, int startIndex)
-
valueOf
public static long valueOf(Long l, long defaultValue)
Null-safe unboxing of Long- Parameters:
l
- value to unboxdefaultValue
- default value to return if l is null
-
-