public final class Assert extends Object
AssertException 应由最外层统一处理| 构造器和说明 |
|---|
Assert() |
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
equals(Object o1,
Object o2,
String message)
对象equals且非null
|
static void |
equalsIgnoreCase(String s1,
String s2,
String message)
字符串equals且非null,忽略大小写
|
static <T> T |
instanceOf(Object target,
Class<T> clazz,
String message)
类型转换
|
static void |
length(String string,
int min,
int max,
String message)
长度处于区间[min, max]
|
static void |
nonBlank(String string,
String message)
非空(包括trim后)
|
static void |
nonEmpty(Object target,
String message)
非空
Object: !
|
static void |
nonNull(Object target,
String message)
非null
|
static void |
oneOf(Object target,
String message,
Object... objs)
target在objs中
|
static void |
require(boolean condition,
ApiCode apiCode)
满足条件condition
|
static void |
require(boolean condition,
String message)
满足条件condition
|
static String |
require(String target,
String regex,
String message)
满足正则regex
|
static <T> void |
require(T target,
java.util.function.Predicate<T> predicate,
String message)
满足条件predicate
|
static String |
trimmedNonBlank(String string,
String message)
非空(包括trim后)
|
public static void require(boolean condition,
String message)
condition - 条件message - 错误信息public static <T> void require(T target,
java.util.function.Predicate<T> predicate,
String message)
T - 对象类型target - 校验对象predicate - 条件message - 错误信息public static void require(boolean condition,
ApiCode apiCode)
condition - 条件apiCode - 错误码public static String require(String target, String regex, String message)
target - 校验对象regex - 正则message - 错误信息public static void nonNull(Object target, String message)
target - 校验对象message - 错误信息public static void nonEmpty(Object target, String message)
target - 校验对象message - 错误信息public static void nonBlank(String string, String message)
string - 校验对象message - 错误信息public static String trimmedNonBlank(String string, String message)
string - 校验对象message - 错误信息public static void length(String string, int min, int max, String message)
string - 校验对象min - 最小长度max - 最大长度message - 错误信息public static void oneOf(Object target, String message, Object... objs)
target - 校验对象message - 错误信息objs - 候选对象public static void equals(Object o1, Object o2, String message)
o1 - 对象1o2 - 对象2message - 错误信息public static void equalsIgnoreCase(String s1, String s2, String message)
s1 - 字符串1s2 - 字符串2message - 错误信息Copyright © 2021. All rights reserved.