public final class Utils extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Utils.ComparingByteArrays
Comparator that performs a lexicographical comparison of byte arrays, treating them as unsigned.
|
static class |
Utils.ComparingByteBuffers |
Modifier and Type | Method and Description |
---|---|
static <T> T |
assertNonNull(T object,
String paramName)
|
static int |
compareObjectIdentity(Object a,
Object b)
Provides an arbitrary but consistent total ordering over all objects.
|
static SecureRandom |
getSecureRandom() |
static long |
saturatingAdd(long a,
long b) |
static byte[] |
truncate(byte[] arr,
int len)
Returns a possibly truncated version of
arr which is guaranteed to be exactly
len elements long. |
public static int compareObjectIdentity(Object a, Object b)
a
- b
- public static long saturatingAdd(long a, long b)
public static <T> T assertNonNull(T object, String paramName) throws NullPointerException
object
- value to be null-checkedparamName
- message for the potential NullPointerException
object
NullPointerException
- if object
is nullpublic static byte[] truncate(byte[] arr, int len) throws IllegalArgumentException
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
.IllegalArgumentException
public static SecureRandom getSecureRandom()
Copyright © 2017. All rights reserved.