| 程序包 | 说明 |
|---|---|
| top.tangyh.basic.utils |
| 限定符和类型 | 方法和说明 |
|---|---|
static int |
ArgumentAssert.checkIndex(int index,
int size)
检查下标(数组、集合、字符串)是否符合要求,下标必须满足:
0 ≤ index < size
|
static int |
ArgumentAssert.checkIndex(int index,
int size,
String errorMsgTemplate,
Object... params)
检查下标(数组、集合、字符串)是否符合要求,下标必须满足:
0 ≤ index < size
|
static <T> T |
ArgumentAssert.contain(Collection<T> collection,
T item)
断言给定值是否被另一个集合包含(即是否不为子串)
Assert.notContain(names, "张三", "name's 中必须包含 '张三'"); |
static <T> T |
ArgumentAssert.contain(Collection<T> collection,
T item,
String errorMsgTemplate,
Object... params)
断言给定值是否被另一个集合包含(即是否不为子串)
Assert.notContain(names, "张三", "name's 中必须包含 '张三'"); |
static void |
ArgumentAssert.isAssignable(Class<?> superType,
Class<?> subType)
断言
superType.isAssignableFrom(subType) 是否为 true. |
static void |
ArgumentAssert.isAssignable(Class<?> superType,
Class<?> subType,
String errorMsgTemplate,
Object... params)
断言
superType.isAssignableFrom(subType) 是否为 true. |
static void |
ArgumentAssert.isFalse(boolean expression)
断言是否为假,如果为
true 抛出 ArgumentException 异常Assert.isFalse(i < 0); |
static void |
ArgumentAssert.isFalse(boolean expression,
String errorMsgTemplate,
Object... params)
断言是否为假,如果为
true 抛出 ArgumentException 异常Assert.isFalse(i < 0, "The value must be greater than zero"); |
static <T> T |
ArgumentAssert.isInstanceOf(Class<?> type,
T obj,
String errorMsgTemplate,
Object... params)
断言给定对象是否是给定类的实例
Assert.instanceOf(Foo.class, foo); |
static void |
ArgumentAssert.isNull(Object object)
|
static void |
ArgumentAssert.isNull(Object object,
String errorMsgTemplate,
Object... params)
|
static void |
ArgumentAssert.isTrue(boolean expression)
断言是否为真,如果为
false 抛出 ArgumentException 异常Assert.isTrue(i > 0, "The value must be greater than zero"); |
static void |
ArgumentAssert.isTrue(boolean expression,
String errorMsgTemplate,
Object... params)
断言是否为真,如果为
false 抛出 ArgumentException 异常Assert.isTrue(i > 0, "The value must be greater than zero"); |
static <T> T[] |
ArgumentAssert.noNullElements(T[] array)
断言给定数组是否不包含
null元素,如果数组为空或 null将被认为不包含
Assert.noNullElements(array); |
static <T> T[] |
ArgumentAssert.noNullElements(T[] array,
String errorMsgTemplate,
Object... params)
断言给定数组是否不包含
null元素,如果数组为空或 null将被认为不包含
Assert.noNullElements(array, "The array must have non-null elements"); |
static <T extends CharSequence> |
ArgumentAssert.notBlank(T text)
检查给定字符串是否为空白(null、空串或只包含空白符),为空抛出
ArgumentException
Assert.notBlank(name, "Name must not be blank"); |
static <T extends CharSequence> |
ArgumentAssert.notBlank(T text,
String errorMsgTemplate,
Object... params)
检查给定字符串是否为空白(null、空串或只包含空白符),为空抛出
ArgumentException
Assert.notBlank(name, "Name must not be blank"); |
static <T> T |
ArgumentAssert.notContain(Collection<T> collection,
T item)
断言给定值是否不被另一个集合包含(即是否为子串)
Assert.notContain(names, "张三", "name's 中不能包含 '张三'"); |
static <T> T |
ArgumentAssert.notContain(Collection<T> collection,
T item,
String errorMsgTemplate,
Object... params)
断言给定值是否不被另一个集合包含(即是否为子串)
Assert.notContain(names, "张三", "name's 中不能包含 '张三'"); |
static String |
ArgumentAssert.notContain(String textToSearch,
String substring)
断言给定字符串是否不被另一个字符串包含(即是否为子串)
Assert.notContain(name, "rod", "Name must not contain 'rod'"); |
static String |
ArgumentAssert.notContain(String textToSearch,
String substring,
String errorMsgTemplate,
Object... params)
断言给定字符串是否不被另一个字符串包含(即是否为子串)
Assert.notContain(name, "rod", "Name must not contain 'rod'"); |
static <E,T extends Iterable<E>> |
ArgumentAssert.notEmpty(T collection)
断言给定集合非空
Assert.notEmpty(collection); |
static <K,V,T extends Map<K,V>> |
ArgumentAssert.notEmpty(T map)
断言给定Map非空
Assert.notEmpty(map, "Map must have entries"); |
static <T extends CharSequence> |
ArgumentAssert.notEmpty(T text)
检查给定字符串是否为空,为空抛出
ArgumentException
Assert.notEmpty(name); |
static <T> T[] |
ArgumentAssert.notEmpty(T[] array)
断言给定数组是否包含元素,数组必须不为
null 且至少包含一个元素
Assert.notEmpty(array, "The array must have elements"); |
static <T> T[] |
ArgumentAssert.notEmpty(T[] array,
String errorMsgTemplate,
Object... params)
断言给定数组是否包含元素,数组必须不为
null 且至少包含一个元素
Assert.notEmpty(array, "The array must have elements"); |
static <E,T extends Iterable<E>> |
ArgumentAssert.notEmpty(T collection,
String errorMsgTemplate,
Object... params)
断言给定集合非空
Assert.notEmpty(collection, "Collection must have elements"); |
static <K,V,T extends Map<K,V>> |
ArgumentAssert.notEmpty(T map,
String errorMsgTemplate,
Object... params)
断言给定Map非空
Assert.notEmpty(map, "Map must have entries"); |
static <T extends CharSequence> |
ArgumentAssert.notEmpty(T text,
String errorMsgTemplate,
Object... params)
检查给定字符串是否为空,为空抛出
ArgumentException
Assert.notEmpty(name, "Name must not be empty"); |
static <T> T |
ArgumentAssert.notNull(T object)
|
static <T> T |
ArgumentAssert.notNull(T object,
String errorMsgTemplate,
Object... params)
|
Copyright © 2022. All rights reserved.