public class Assert extends Object
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
hasLength(String text,
String message)
assert the given string is not empty.
|
static void |
isTrue(boolean expression,
String message)
Assert a boolean expression,throwing
IllegalArgumentException if the test result is false. |
static void |
notEmpty(boolean[] array,
String message)
Assert that the array has one boolean element at least.
|
static void |
notEmpty(byte[] array,
String message)
Assert that the array has one byte element at least.
|
static void |
notEmpty(char[] array,
String message)
Assert that the array has one char element at least.
|
static void |
notEmpty(Collection<?> collection,
String message)
Assert that the collection has one element at least.
|
static void |
notEmpty(double[] array,
String message)
Assert that the array has one doube element at least.
|
static void |
notEmpty(float[] array,
String message)
Assert that the array has one float element at least.
|
static void |
notEmpty(int[] array,
String message)
Assert that the array has one int element at least.
|
static void |
notEmpty(long[] array,
String message)
Assert that the array has one long element at least.
|
static void |
notEmpty(Map<?,?> map,
String message)
Assert that the map has one entry at least.
|
static void |
notEmpty(short[] array,
String message)
Assert that the array has one short element at least.
|
static <T> void |
notEmpty(T[] array,
String message)
Assert that the array has one element at least.
|
static void |
notNull(Object data,
String message)
Assert an object value is not
null,throwing IllegalArgumentException if the test result is false. |
public static void isTrue(boolean expression,
String message)
IllegalArgumentException if the test result is false.
Assert.isTrue(i > 0, "The value must be greater than zero");
expression - a boolean expressionmessage - the detail message.IllegalArgumentException - An invalid parameter exception.public static void notNull(Object data, String message)
null,throwing IllegalArgumentException if the test result is false.
Assert.notNull(clazz, "The class must not be null");
data - the object to checkmessage - the detail message.IllegalArgumentException - An invalid parameter exception.public static void hasLength(String text, String message)
Assert.hasLength(name, "Name must not be empty");
text - the string to checkmessage - the detail message.IllegalArgumentException - An invalid parameter exception.public static void notEmpty(Collection<?> collection, String message)
Assert.notEmpty(collection, "Collection must have elements");
collection - the collection to checkmessage - the detail message.IllegalArgumentException - An invalid parameter exception.public static void notEmpty(Map<?,?> map, String message)
Assert.notEmpty(map, "Map must have entries");
map - the map to checkmessage - the detail message.IllegalArgumentException - An invalid parameter exception.public static <T> void notEmpty(T[] array,
String message)
Assert.notEmpty(array, "The array must have elements");
T - generic typearray - the array to checkmessage - the detail message.IllegalArgumentException - An invalid parameter exception.public static void notEmpty(char[] array,
String message)
Assert.notEmpty(new char[]{}, "The array must have elements");array - the array to checkmessage - the detail message.IllegalArgumentException - An invalid parameter exception.public static void notEmpty(boolean[] array,
String message)
Assert.notEmpty(new boolean[]{}, "The array must have elements");array - the array to checkmessage - the detail message.IllegalArgumentException - An invalid parameter exception.public static void notEmpty(byte[] array,
String message)
Assert.notEmpty(new byte[]{}, "The array must have elements");array - the array to checkmessage - the detail message.IllegalArgumentException - An invalid parameter exception.public static void notEmpty(short[] array,
String message)
Assert.notEmpty(new short[]{}, "The array must have elements");array - the array to checkmessage - the detail message.IllegalArgumentException - An invalid parameter exception.public static void notEmpty(int[] array,
String message)
Assert.notEmpty(new int[]{}, "The array must have elements");array - the array to checkmessage - the detail message.IllegalArgumentException - An invalid parameter exception.public static void notEmpty(long[] array,
String message)
Assert.notEmpty(new long[]{}, "The array must have elements");array - the array to checkmessage - the detail message.IllegalArgumentException - An invalid parameter exception.public static void notEmpty(float[] array,
String message)
Assert.notEmpty(new float[]{}, "The array must have elements");array - the array to checkmessage - the detail message.IllegalArgumentException - An invalid parameter exception.public static void notEmpty(double[] array,
String message)
Assert.notEmpty(new double[]{}, "The array must have elements");array - the array to checkmessage - the detail message.IllegalArgumentException - An invalid parameter exception.Copyright © 2017. All rights reserved.