public final class Validate extends Object
| Modifier and Type | Method and Description |
|---|---|
static Object |
ensureNotNull(Object obj)
Verifies the input object is not null, and returns that object.
|
static Object |
ensureNotNull(Object obj,
String msg,
Object... args)
Verifies the input object is not null, and returns that object.
|
static void |
fail(String msg)
Cause a failure.
|
static void |
isFalse(boolean val)
Validates that the value is false
|
static void |
isFalse(boolean val,
String msg)
Validates that the value is false
|
static void |
isTrue(boolean val)
Validates that the value is true
|
static void |
isTrue(boolean val,
String msg)
Validates that the value is true
|
static void |
noNullElements(Object[] objects)
Validates that the array contains no null elements
|
static void |
noNullElements(Object[] objects,
String msg)
Validates that the array contains no null elements
|
static void |
notEmpty(String string)
Validates that the string is not null and is not empty
|
static void |
notEmpty(String string,
String msg)
Validates that the string is not null and is not empty
|
static void |
notEmptyParam(String string,
String param)
Validates that the string parameter is not null and is not empty
|
static void |
notNull(Object obj)
Validates that the object is not null
|
static void |
notNull(Object obj,
String msg)
Validates that the object is not null
|
static void |
notNullParam(Object obj,
String param)
Validates that the parameter is not null
|
static void |
wtf(String msg)
Blow up if we reach an unexpected state.
|
public static void notNull(@Nullable Object obj)
obj - object to testValidationException - if the object is nullpublic static void notNullParam(@Nullable Object obj, String param)
obj - the parameter to testparam - the name of the parameter, for presentation in the validation exception.ValidationException - if the object is nullpublic static void notNull(@Nullable Object obj, String msg)
obj - object to testmsg - message to include in the Exception if validation failsValidationException - if the object is nullpublic static Object ensureNotNull(@Nullable Object obj)
obj - nullable object to case to not-nullValidationException - if the object is nullpublic static Object ensureNotNull(@Nullable Object obj, String msg, Object... args)
obj - nullable object to case to not-nullmsg - the String format message to include in the validation exception when thrownargs - the arguments to the msgValidationException - if the object is nullpublic static void isTrue(boolean val)
val - object to testValidationException - if the object is not truepublic static void isTrue(boolean val,
String msg)
val - object to testmsg - message to include in the Exception if validation failsValidationException - if the object is not truepublic static void isFalse(boolean val)
val - object to testValidationException - if the object is not falsepublic static void isFalse(boolean val,
String msg)
val - object to testmsg - message to include in the Exception if validation failsValidationException - if the object is not falsepublic static void noNullElements(Object[] objects)
objects - the array to testValidationException - if the array contains a null elementpublic static void noNullElements(Object[] objects, String msg)
objects - the array to testmsg - message to include in the Exception if validation failsValidationException - if the array contains a null elementpublic static void notEmpty(@Nullable String string)
string - the string to testValidationException - if the string is null or emptypublic static void notEmptyParam(@Nullable String string, String param)
string - the string to testparam - the name of the parameter, for presentation in the validation exception.ValidationException - if the string is null or emptypublic static void notEmpty(@Nullable String string, String msg)
string - the string to testmsg - message to include in the Exception if validation failsValidationException - if the string is null or emptypublic static void wtf(String msg)
msg - message to think aboutIllegalStateException - if we reach this statepublic static void fail(String msg)
msg - message to output.IllegalStateException - if we reach this stateCopyright © 2009–2022 Jonathan Hedley. All rights reserved.