Class NumberUtils

    • Field Detail

      • NUMERIC_PRIMITIVE_CLASSES

        public static final List<Class<?>> NUMERIC_PRIMITIVE_CLASSES
        A List of all the Class types used to represent the primitive numerical values
    • Method Detail

      • getNextPowerOf2

        public static int getNextPowerOf2​(int value)
        Parameters:
        value - The original (non-negative) value
        Returns:
        The closest positive power of 2 that is greater or equal to the value. If none can be found then returns the original value
      • hashCode

        public static int hashCode​(long... values)
      • hashCode

        public static int hashCode​(int... values)
      • hashCode

        public static int hashCode​(byte... values)
      • hashCode

        public static int hashCode​(byte[] a,
                                   int offset,
                                   int len)
      • diffOffset

        public static int diffOffset​(byte[] a1,
                                     int startPos1,
                                     byte[] a2,
                                     int startPos2,
                                     int len)
      • isNumericClass

        public static boolean isNumericClass​(Class<?> clazz)
        Parameters:
        clazz - The Class to examine - ignored if null
        Returns:
        If the class is a Number or one of the primitive numerical types
        See Also:
        NUMERIC_PRIMITIVE_CLASSES
      • toInteger

        public static Integer toInteger​(Number n)
        Converts a Number into an Integer if not already such
        Parameters:
        n - The Number - ignored if null
        Returns:
        The equivalent Integer value
      • join

        public static String join​(char separator,
                                  long... values)
      • join

        public static String join​(CharSequence separator,
                                  boolean unsigned,
                                  byte... values)
      • join

        public static String join​(char separator,
                                  boolean unsigned,
                                  byte... values)
      • join

        public static String join​(char separator,
                                  int... values)
      • emptyIfNull

        public static byte[] emptyIfNull​(byte[] a)
      • isEmpty

        public static boolean isEmpty​(byte[] a)
      • isEmpty

        public static boolean isEmpty​(int[] a)
      • isEmpty

        public static boolean isEmpty​(long[] a)
      • length

        public static int length​(byte... a)
      • length

        public static int length​(int... a)
      • length

        public static int length​(long... a)
      • asList

        public static List<Integer> asList​(int... values)
      • isIntegerNumber

        public static boolean isIntegerNumber​(CharSequence cs)
        Checks if optional sign and all others are '0'-'9'
        Parameters:
        cs - The CharSequence to check
        Returns:
        true if valid integer number