Class Utils


  • public final class Utils
    extends Object
    Internal utility methods.
    • Method Detail

      • compareObjectIdentity

        public static int compareObjectIdentity​(Object a,
                                                Object b)
        Provides an arbitrary but consistent total ordering over all objects. This comparison function will return 0 if and only if a == b, and otherwise will return arbitrarily either -1 or 1, but will do so in a way that results in a consistent total order.
        Parameters:
        a -
        b -
        Returns:
        -1 or 1 (consistently) if a != b; 0 if a == b.
      • saturatingAdd

        public static long saturatingAdd​(long a,
                                         long b)
      • truncate

        public static byte[] truncate​(byte[] arr,
                                      int len)
                               throws IllegalArgumentException
        Returns a possibly truncated version of arr which is guaranteed to be exactly len elements long. If arr is already exactly len elements long, then arr is returned without copy or modification. If arr is longer than len, then a truncated copy is returned. If arr is shorter than len then this throws an IllegalArgumentException.
        Throws:
        IllegalArgumentException
      • getSecureRandom

        public static SecureRandom getSecureRandom()