public abstract class Assert extends Object
Useful for identifying programmer errors early and clearly at runtime.
For example, if the contract of a public method states it does not
allow null arguments, Assert can be used to validate that
contract.
For example:
Assert.notNull(clazz, "The class must not be null"); Assert.isTrue(i > 0, "The value must be greater than zero");This class is empowered by
Assert| 构造器和说明 |
|---|
Assert() |
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
isTrue(boolean expression) |
static void |
isTrue(boolean expression,
com.alibaba.cola.dto.ErrorCodeI errorCode,
String message)
Assert a boolean expression, throwing
BizException
for example
Assert.isTrue(i ! |
static void |
isTrue(boolean expression,
String message) |
static void |
notEmpty(Collection<?> collection) |
static void |
notEmpty(Collection<?> collection,
String message) |
static void |
notEmpty(Map<?,?> map) |
static void |
notEmpty(Map<?,?> map,
String message) |
static void |
notNull(Object object) |
static void |
notNull(Object object,
com.alibaba.cola.dto.ErrorCodeI errorCode,
String message) |
static void |
notNull(Object object,
String message) |
public static void isTrue(boolean expression,
com.alibaba.cola.dto.ErrorCodeI errorCode,
String message)
BizException
for example
Assert.isTrue(i != 0, errorCode.B_ORDER_illegalNumber, "The order number can not be zero");
expression - a boolean expressionerrorCode - message - the exception message to use if the assertion failsBizException - if expression is falsepublic static void isTrue(boolean expression,
String message)
public static void isTrue(boolean expression)
public static void notNull(Object object, com.alibaba.cola.dto.ErrorCodeI errorCode, String message)
public static void notNull(Object object)
public static void notEmpty(Collection<?> collection)
public static void notEmpty(Collection<?> collection, String message)
public static void notEmpty(Map<?,?> map)
Copyright © 2020. All rights reserved.