Class PreConditions
- java.lang.Object
-
- com.github.mjeanroy.dbunit.commons.lang.PreConditions
-
public final class PreConditions extends Object
Static PreConditions Utilities.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
checkArgument(boolean condition, String message, Object... params)
static char
notBlank(char value, String message, Object... params)
Ensure that givenvalue
is not blank.static String
notBlank(String value, String message, Object... params)
Ensure that givenvalue
is notnull
, empty or blank.static <T> T
notNull(T value, String message, Object... params)
Ensure that givenvalue
is notnull
.static String
startsWith(String value, String prefix, String message, Object... params)
Ensure that givenvalue
is notnull
, empty or blank and starts with givenprefix
.
-
-
-
Method Detail
-
notNull
public static <T> T notNull(T value, String message, Object... params)
Ensure that givenvalue
is notnull
.- Type Parameters:
T
- Type of value.- Parameters:
value
- Value to check.message
- Error message.params
- Optional error message parameters.- Returns:
- Value if it is not null.
- Throws:
NullPointerException
- Ifvalue
is null.
-
notBlank
public static String notBlank(String value, String message, Object... params)
Ensure that givenvalue
is notnull
, empty or blank.- Parameters:
value
- Value to check.message
- Error message.params
- Optional error message parameters.- Returns:
- Value if it is not
null
, empty or blank. - Throws:
NullPointerException
- Ifvalue
is null.IllegalArgumentException
- Ifvalue
is empty or blank.
-
notBlank
public static char notBlank(char value, String message, Object... params)
Ensure that givenvalue
is not blank.- Parameters:
value
- Value to check.message
- Error message.params
- Optional error message parameters.- Returns:
- Value if it is not
null
, empty or blank. - Throws:
NullPointerException
- Ifvalue
is null.IllegalArgumentException
- Ifvalue
is empty or blank.
-
startsWith
public static String startsWith(String value, String prefix, String message, Object... params)
Ensure that givenvalue
is notnull
, empty or blank and starts with givenprefix
.- Parameters:
value
- Value to check.prefix
- The prefix to look for.message
- Error message.params
- Optional error message parameters.- Returns:
- Value if it is not
null
, empty or blank. - Throws:
NullPointerException
- Ifvalue
is null.IllegalArgumentException
- Ifvalue
is empty, blank, or does not start withprefix
.
-
-