public final class Utils extends Object
Modifier and Type | Method and Description |
---|---|
static <T> T |
assertNonNull(T object,
String paramName)
|
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 <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
Copyright © 2016. All rights reserved.