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 voidarrayStore(int number, @org.jetbrains.annotations.NotNull byte[] array, int startIndex)static voidarrayStore(long number, @org.jetbrains.annotations.NotNull byte[] array, int startIndex)static @Nullable DoublecreateDoubleQuietly(@Nullable String s)seeNumberUtils.createDouble(String).static NumberUtilsgetInstance()static booleanisPositiveInteger(@Nullable String input)static intmax(int a, int b)static <T extends Comparable<? super T>>
Tmax(@NotNull Collection<T> collection)static intmin(int a, int b)static StringpadWithZeroes(Number value, int numberOfZeroes)static longrandomNonNegativeLong()static doubleround(double val, int places)static floatround(float val, int places)static doublestringToDouble(String s)Deprecated.since 4.2 consider usingcreateDoubleQuietly(String)static intstringToInt(String s)static longstringToLong(String s)static @Nullable IntegertoInteger(@Nullable Number number)static doubleunlocalizedStringToDouble(@Nullable String s)Convert string to double value.static longvalueOf(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
-
-