public final class ObjectUtil extends Object
| 限定符和类型 | 方法和说明 |
|---|---|
static <T> T[] |
checkNonEmpty(T[] array,
String name)
Checks that the given argument is neither null nor empty.
|
static <T extends Collection<?>> |
checkNonEmpty(T collection,
String name)
Checks that the given argument is neither null nor empty.
|
static <T> T |
checkNotNull(T arg,
String text)
Checks that the given argument is not null.
|
static int |
checkPositive(int i,
String name)
检查是否是正数 >0
Checks that the given argument is strictly positive.
|
static long |
checkPositive(long i,
String name)
Checks that the given argument is strictly positive.
|
static int |
checkPositiveOrZero(int i,
String name)
Checks that the given argument is positive or zero.
|
static long |
checkPositiveOrZero(long i,
String name)
Checks that the given argument is positive or zero.
|
static int |
intValue(Integer wrapper,
int defaultValue)
Resolves a possibly null Integer to a primitive int, using a default value.
|
static byte[] |
longToByte(long i)
方法名:longToByte
@param i
@return
返回类型:byte[]
|
static long |
longValue(Long wrapper,
long defaultValue)
Resolves a possibly null Long to a primitive long, using a default value.
|
static byte[] |
ObjToByteArray(Object obj)
对象转数组
|
static byte[] |
shortToByte(int i)
方法名:shortToByte
@param i
@return
返回类型:byte[]
|
static int |
toInt(byte... b)
方法名:toInt
@param b
@return
返回类型:int
|
static long |
toLong(byte... b)
方法名:toLong
@param b
@return
返回类型:long
|
public static <T> T checkNotNull(T arg,
String text)
NullPointerException.
Otherwise, returns the argument.arg - argtext - textpublic static int checkPositive(int i,
String name)
IllegalArgumentException.
Otherwise, returns the argument.i - iname - namepublic static long checkPositive(long i,
String name)
IllegalArgumentException.
Otherwise, returns the argument.i - iname - namepublic static int checkPositiveOrZero(int i,
String name)
IllegalArgumentException.
Otherwise, returns the argument.i - iname - namepublic static long checkPositiveOrZero(long i,
String name)
IllegalArgumentException.
Otherwise, returns the argument.i - iname - namepublic static <T> T[] checkNonEmpty(T[] array,
String name)
NullPointerException or IllegalArgumentException.
Otherwise, returns the argument.name - namearray - arraypublic static <T extends Collection<?>> T checkNonEmpty(T collection, String name)
NullPointerException or IllegalArgumentException.
Otherwise, returns the argument.name - namecollection - collectionpublic static int intValue(Integer wrapper, int defaultValue)
wrapper - the wrapperdefaultValue - the default valuepublic static long longValue(Long wrapper, long defaultValue)
wrapper - the wrapperdefaultValue - the default valuepublic static int toInt(byte... b)
public static long toLong(byte... b)
public static byte[] shortToByte(int i)
public static byte[] longToByte(long i)
public static byte[] ObjToByteArray(Object obj)
obj - Copyright © 2021. All rights reserved.