Class Integers
java.lang.Object
com.pnfsoftware.jeb.util.primitives.Integers
Utility methods for
int
s-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
Format a collection of ints.static String
formatIntegerCollection
(Collection<Integer> collection, Integer radix, String pfx, String sfx) Format a collection of ints.static String
formatIntegerCollection
(Collection<Integer> collection, Integer radix, String pfx, String sfx, String separator) static Integer
max
(Collection<Integer> c) static Integer
min
(Collection<Integer> c) range
(int cnt) Generate an incremental range of integers from 0 to the provided count.range
(int start, int end) Generate an incremental range of integers.range
(int start, int end, int step) Generate an iterable range of integers.static int
Safe unbox an Integer to zero when null.static Integer
Safe unbox an Integer to defaultValue when null.static String
toUnsignedString
(int value)
-
Constructor Details
-
Integers
public Integers()
-
-
Method Details
-
toUnsignedString
-
safeInt
Safe unbox an Integer to zero when null.- Parameters:
v
- an Integer object- Returns:
- the integer value, 0 if null
-
safeInt
Safe unbox an Integer to defaultValue when null.- Parameters:
v
- an Integer objectdefaultValue
- default value if null- Returns:
- the integer value, defaultValue if null
-
min
- Parameters:
c
-- Returns:
-
max
- Parameters:
c
-- Returns:
-
formatIntegerCollection
public static String formatIntegerCollection(Collection<Integer> collection, Integer radix, String pfx, String sfx) Format a collection of ints.- Parameters:
collection
-radix
-pfx
-sfx
-- Returns:
-
formatHexIntegerCollection
Format a collection of ints.- Parameters:
collection
- collection of intslist
-- Returns:
-
formatIntegerCollection
public static String formatIntegerCollection(Collection<Integer> collection, Integer radix, String pfx, String sfx, String separator) - Parameters:
collection
-radix
- optional, default=10pfx
- optional, default=nonesfx
- optional, default=noneseparator
-- Returns:
-
range
Generate an iterable range of integers.- Parameters:
start
-end
- exclusivestep
- increment (can be negative, cannot be zero)- Returns:
-
range
Generate an incremental range of integers.- Parameters:
start
-end
- exclusive- Returns:
-
range
Generate an incremental range of integers from 0 to the provided count.- Parameters:
cnt
-- Returns:
-