public abstract class AssertUtils extends Object
Description: This class has some apis to validate parameter , if you want more about validate object or array
please use Assert instead.
| 构造器和说明 |
|---|
AssertUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
isNull(Object object,
String name)
Assert that an object is
null. |
static void |
isTrue(boolean expression,
String name)
Assert a boolean expression, throwing an
IllegalStateException
if the expression evaluates to false. |
static void |
length(String value,
String name,
int min,
int max)
Assert that value is in size [min~max]
AssetUtils.length(obj,name,0,12)
name out of size[0~12]
name out of size[0~]
name out of size[~12]
|
static void |
notNull(Object object,
String name)
Assert that an object is not
null. |
static void |
notNull(String string,
String name)
Assert that an object is not
null. |
static void |
notZero(Number number,
String name) |
static void |
range(Number value,
String name,
int min,
int max)
Assert number or range [min~max]
|
public static void isTrue(boolean expression,
String name)
IllegalStateException
if the expression evaluates to false.
AssetUtils.state(id == null, "name");
expression - a boolean expressionname - the exception message to use if the assertion fails like 'name is not true'ServiceException - if expression is falsepublic static void isNull(@Nullable
Object object,
String name)
null.
AssetUtils.isNull(value, "name");
object - the object to checkname - the exception message to use if the assertion failsServiceException - if the object is not null 'name must be null!'public static void notNull(@Nullable
Object object,
String name)
null.
AssetUtils.notNull(clazz, "name");
object - the object to checkname - the exception message to use if the assertion failsServiceException - if the object is nullpublic static void notNull(@Nullable
String string,
String name)
null.
AssetUtils.notNull(clazz, "name");
string - the string to checkname - the exception message to use if the assertion failsServiceException - if the object is nullpublic static void notZero(Number number, String name)
number - name - name of number 'name must not be zero'ServiceException - if the number is null or 0public static void length(String value, String name, int min, int max)
AssetUtils.length(obj,name,0,12)
min - minimum size of value . -1 of skip validatemax - maximum size of value . -1 of skip validatename - name of valueServiceException - if value size out of min ~ max.Copyright © 2020. All rights reserved.