public abstract class Assert extends Object
For example:
public void setName(String name) {
this.name = Assert.notEmpty(name, "Name cannot be empty!");
}
| Constructor and Description |
|---|
Assert() |
| Modifier and Type | Method and Description |
|---|---|
protected static IllegalArgumentException |
assertError(String message)
Returns
IllegalArgumentException initialized with the
specified message and with adjusted stack trace. |
static void |
assertFalse(boolean flag,
String message)
Throws
IllegalArgumentException if the specified flag is
true. |
static void |
assertTrue(boolean flag,
String message)
Throws
IllegalArgumentException if the specified flag is
false. |
static String[] |
noEmptyElements(String[] array,
String message)
Throws
IllegalArgumentException if the specified array is
null or empty or contains null or empty
strings. |
static <T extends Collection<String>> |
noEmptyElements(T collection,
String message)
Throws
IllegalArgumentException if the specified collection
is null or empty or contains null or empty
strings. |
static Set<String> |
noEmptyStringSet(String[] array,
String message)
Throws
IllegalArgumentException if the specified array is
null or empty or contains null or empty
strings. |
static <T> T[] |
noNullElements(T[] array,
String message)
Throws
IllegalArgumentException if the specified array is
null or empty or contains null elements. |
static <T extends Collection<?>> |
noNullElements(T collection,
String message)
Throws
IllegalArgumentException if the specified collection
is null or empty or contains null elements. |
static Set<String> |
noNullStringSet(String[] array,
String message)
Throws
IllegalArgumentException if the specified array is
null or empty or contains null strings. |
static String |
notEmpty(String string,
String message)
Throws
IllegalArgumentException if the specified string is
null or empty. |
static <T> T[] |
notEmpty(T[] array,
String message)
Throws
IllegalArgumentException if the specified array is
null or empty. |
static <T extends Collection<?>> |
notEmpty(T collection,
String message)
Throws
IllegalArgumentException if the specified collection
is null or empty. |
static double |
notNegative(double value,
String message)
Throws
IllegalArgumentException if the specified
double value is negative. |
static float |
notNegative(float value,
String message)
Throws
IllegalArgumentException if the specified
float value is negative. |
static int |
notNegative(int value,
String message)
Throws
IllegalArgumentException if the specified
int value is negative. |
static long |
notNegative(long value,
String message)
Throws
IllegalArgumentException if the specified
long value is negative. |
static double |
notNegativeOrZero(double value,
String message)
Throws
IllegalArgumentException if the specified
double value is negative or zero. |
static float |
notNegativeOrZero(float value,
String message)
Throws
IllegalArgumentException if the specified
float value is negative or zero. |
static int |
notNegativeOrZero(int value,
String message)
Throws
IllegalArgumentException if the specified
int value is negative or zero. |
static long |
notNegativeOrZero(long value,
String message)
Throws
IllegalArgumentException if the specified
long value is negative or zero. |
static <T> T |
notNull(T object,
String message)
Throws
IllegalArgumentException if the specified object is
null. |
public static void assertTrue(boolean flag,
String message)
IllegalArgumentException if the specified flag is
false.flag - Test flag.message - Exception message.IllegalArgumentException - if the specified flag is
false.public static void assertFalse(boolean flag,
String message)
IllegalArgumentException if the specified flag is
true.flag - Test flag.message - Exception message.IllegalArgumentException - if the specified flag is
true.public static <T> T notNull(T object,
String message)
IllegalArgumentException if the specified object is
null.object - Object to test.message - Exception message.IllegalArgumentException - if the specified object is
null.public static String notEmpty(String string, String message)
IllegalArgumentException if the specified string is
null or empty.string - String to test.message - Exception message.IllegalArgumentException - if the specified string is
null or empty.public static <T> T[] notEmpty(T[] array,
String message)
IllegalArgumentException if the specified array is
null or empty.array - Array to test.message - Exception message.IllegalArgumentException - if the specified array is
null or empty.public static <T extends Collection<?>> T notEmpty(T collection, String message)
IllegalArgumentException if the specified collection
is null or empty.collection - Collection to test.message - Exception message.IllegalArgumentException - if the specified collection is
null or empty.public static <T> T[] noNullElements(T[] array,
String message)
IllegalArgumentException if the specified array is
null or empty or contains null elements.array - Array to test.message - Exception message.IllegalArgumentException - if the specified array is
null or empty or contains null
elements.public static <T extends Collection<?>> T noNullElements(T collection, String message)
IllegalArgumentException if the specified collection
is null or empty or contains null elements.collection - Collection to test.message - Exception message.IllegalArgumentException - if the specified collection is
null or empty or contains null
elements.public static String[] noEmptyElements(String[] array, String message)
IllegalArgumentException if the specified array is
null or empty or contains null or empty
strings.array - Array to test.message - Exception message.IllegalArgumentException - if the specified array is
null or empty or contains null
or empty strings.public static <T extends Collection<String>> T noEmptyElements(T collection, String message)
IllegalArgumentException if the specified collection
is null or empty or contains null or empty
strings.collection - Collection to test.message - Exception message.IllegalArgumentException - if the specified collection is
null or empty or contains null
or empty strings.public static Set<String> noNullStringSet(String[] array, String message)
IllegalArgumentException if the specified array is
null or empty or contains null strings.array - Array to test.message - Exception message.IllegalArgumentException - if the specified array is
null or empty or contains null
strings.public static Set<String> noEmptyStringSet(String[] array, String message)
IllegalArgumentException if the specified array is
null or empty or contains null or empty
strings.array - Array to test.message - Exception message.IllegalArgumentException - if the specified array is
null or empty or contains null
or empty strings.public static int notNegative(int value,
String message)
IllegalArgumentException if the specified
int value is negative.value - Value to test.message - Exception message.IllegalArgumentException - if the specified value is negative.public static long notNegative(long value,
String message)
IllegalArgumentException if the specified
long value is negative.value - Value to test.message - Exception message.IllegalArgumentException - if the specified value is negative.public static float notNegative(float value,
String message)
IllegalArgumentException if the specified
float value is negative.value - Value to test.message - Exception message.IllegalArgumentException - if the specified value is negative.public static double notNegative(double value,
String message)
IllegalArgumentException if the specified
double value is negative.value - Value to test.message - Exception message.IllegalArgumentException - if the specified value is negative.public static int notNegativeOrZero(int value,
String message)
IllegalArgumentException if the specified
int value is negative or zero.value - Value to test.message - Exception message.IllegalArgumentException - if the specified value is negative or
zero.public static long notNegativeOrZero(long value,
String message)
IllegalArgumentException if the specified
long value is negative or zero.value - Value to test.message - Exception message.IllegalArgumentException - if the specified value is negative or
zero.public static float notNegativeOrZero(float value,
String message)
IllegalArgumentException if the specified
float value is negative or zero.value - Value to test.message - Exception message.IllegalArgumentException - if the specified value is negative or
zero.public static double notNegativeOrZero(double value,
String message)
IllegalArgumentException if the specified
double value is negative or zero.value - Value to test.message - Exception message.IllegalArgumentException - if the specified value is negative or
zero.protected static IllegalArgumentException assertError(String message)
IllegalArgumentException initialized with the
specified message and with adjusted stack trace.message - Exception message.IllegalArgumentException.Copyright © 2010-2012 FoxLabs. All Rights Reserved.