Class Integers

java.lang.Object
com.pnfsoftware.jeb.util.primitives.Integers

public class Integers extends Object
Utility methods for ints
  • Constructor Details

    • Integers

      public Integers()
  • Method Details

    • toUnsignedString

      public static String toUnsignedString(int value)
    • safeInt

      public static int safeInt(Integer v)
      Safe unbox an Integer to zero when null.
      Parameters:
      v - an Integer object
      Returns:
      the integer value, 0 if null
    • safeInt

      public static Integer safeInt(Integer v, int defaultValue)
      Safe unbox an Integer to defaultValue when null.
      Parameters:
      v - an Integer object
      defaultValue - default value if null
      Returns:
      the integer value, defaultValue if null
    • min

      public static Integer min(Collection<Integer> c)
      Parameters:
      c -
      Returns:
    • max

      public static Integer max(Collection<Integer> c)
      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

      public static String formatHexIntegerCollection(Collection<Integer> list)
      Format a collection of ints.
      Parameters:
      collection - collection of ints
      list -
      Returns:
    • formatIntegerCollection

      public static String formatIntegerCollection(Collection<Integer> collection, Integer radix, String pfx, String sfx, String separator)
      Parameters:
      collection -
      radix - optional, default=10
      pfx - optional, default=none
      sfx - optional, default=none
      separator -
      Returns:
    • range

      public static Iterable<Integer> range(int start, int end, int step)
      Generate an iterable range of integers.
      Parameters:
      start -
      end - exclusive
      step - increment (can be negative, cannot be zero)
      Returns:
    • range

      public static Iterable<Integer> range(int start, int end)
      Generate an incremental range of integers.
      Parameters:
      start -
      end - exclusive
      Returns:
    • range

      public static Iterable<Integer> range(int cnt)
      Generate an incremental range of integers from 0 to the provided count.
      Parameters:
      cnt -
      Returns: