Class Integers
java.lang.Object
com.pnfsoftware.jeb.util.primitives.Integers
Utility methods for
ints-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringFormat a collection of ints.static StringformatIntegerCollection(Collection<Integer> collection, Integer radix, String pfx, String sfx) Format a collection of ints.static StringformatIntegerCollection(Collection<Integer> collection, Integer radix, String pfx, String sfx, String separator) Format a collection of ints.static Integermax(Collection<Integer> c) Retrieve the greatest integer in a collection.static Integermin(Collection<Integer> c) Retrieve the smallest integer in a collection.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 intSafe unbox an Integer to zero when null.static IntegerSafe unbox an Integer to defaultValue when null.static StringtoUnsignedString(int value) Convert an int to its unsigned decimal string representation.
-
Constructor Details
-
Integers
public Integers()
-
-
Method Details
-
toUnsignedString
Convert an int to its unsigned decimal string representation.- Parameters:
value- int value- Returns:
- the unsigned decimal representation of
value
-
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
Retrieve the smallest integer in a collection.- Parameters:
c- collection to scan- Returns:
- the smallest value, or null if the collection is empty
-
max
Retrieve the greatest integer in a collection.- Parameters:
c- collection to scan- Returns:
- the greatest value, or null if the collection is empty
-
formatIntegerCollection
public static String formatIntegerCollection(Collection<Integer> collection, Integer radix, String pfx, String sfx) Format a collection of ints.- Parameters:
collection- collection of intsradix- optional radix, default=10pfx- optional prefix, default=nonesfx- optional suffix, default=none- Returns:
- the formatted collection
-
formatHexIntegerCollection
Format a collection of ints.- Parameters:
list- collection of ints- Returns:
- the formatted hexadecimal collection
-
formatIntegerCollection
public static String formatIntegerCollection(Collection<Integer> collection, Integer radix, String pfx, String sfx, String separator) Format a collection of ints.- Parameters:
collection- collection of intsradix- optional, default=10pfx- optional, default=nonesfx- optional, default=noneseparator- optional separator, default=", "- Returns:
- the formatted collection
-
range
Generate an iterable range of integers.- Parameters:
start- first value, inclusiveend- exclusivestep- increment (can be negative, cannot be zero)- Returns:
- an iterable range
-
range
Generate an incremental range of integers.- Parameters:
start- first value, inclusiveend- exclusive- Returns:
- an iterable range
-
range
Generate an incremental range of integers from 0 to the provided count.- Parameters:
cnt- exclusive upper bound- Returns:
- an iterable range from 0 to
cnt
-