Package org.jsoup.helper
Class Validate
- java.lang.Object
-
- org.jsoup.helper.Validate
-
public final class Validate extends java.lang.ObjectSimple validation methods. Designed for jsoup internal use.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.ObjectensureNotNull(java.lang.Object obj)Verifies the input object is not null, and returns that object.static voidfail(java.lang.String msg)Cause a failure.static voidisFalse(boolean val)Validates that the value is falsestatic voidisFalse(boolean val, java.lang.String msg)Validates that the value is falsestatic voidisTrue(boolean val)Validates that the value is truestatic voidisTrue(boolean val, java.lang.String msg)Validates that the value is truestatic voidnoNullElements(java.lang.Object[] objects)Validates that the array contains no null elementsstatic voidnoNullElements(java.lang.Object[] objects, java.lang.String msg)Validates that the array contains no null elementsstatic voidnotEmpty(java.lang.String string)Validates that the string is not null and is not emptystatic voidnotEmpty(java.lang.String string, java.lang.String msg)Validates that the string is not null and is not emptystatic voidnotNull(java.lang.Object obj)Validates that the object is not nullstatic voidnotNull(java.lang.Object obj, java.lang.String msg)Validates that the object is not nullstatic voidwtf(java.lang.String msg)Blow up if we reach an unexpected state.
-
-
-
Method Detail
-
notNull
public static void notNull(@Nullable java.lang.Object obj)Validates that the object is not null- Parameters:
obj- object to test- Throws:
java.lang.IllegalArgumentException- if the object is null
-
notNull
public static void notNull(@Nullable java.lang.Object obj, java.lang.String msg)Validates that the object is not null- Parameters:
obj- object to testmsg- message to include in the Exception if validation fails- Throws:
java.lang.IllegalArgumentException- if the object is null
-
ensureNotNull
public static java.lang.Object ensureNotNull(@Nullable java.lang.Object obj)Verifies the input object is not null, and returns that object. Effectively this casts a nullable object to a non- null object. (Works around lack of Objects.requestNonNull in Android version.)- Parameters:
obj- nullable object to case to not-null- Returns:
- the object, or throws an exception if it is null
- Throws:
java.lang.IllegalArgumentException- if the object is null
-
isTrue
public static void isTrue(boolean val)
Validates that the value is true- Parameters:
val- object to test- Throws:
java.lang.IllegalArgumentException- if the object is not true
-
isTrue
public static void isTrue(boolean val, java.lang.String msg)Validates that the value is true- Parameters:
val- object to testmsg- message to include in the Exception if validation fails- Throws:
java.lang.IllegalArgumentException- if the object is not true
-
isFalse
public static void isFalse(boolean val)
Validates that the value is false- Parameters:
val- object to test- Throws:
java.lang.IllegalArgumentException- if the object is not false
-
isFalse
public static void isFalse(boolean val, java.lang.String msg)Validates that the value is false- Parameters:
val- object to testmsg- message to include in the Exception if validation fails- Throws:
java.lang.IllegalArgumentException- if the object is not false
-
noNullElements
public static void noNullElements(java.lang.Object[] objects)
Validates that the array contains no null elements- Parameters:
objects- the array to test- Throws:
java.lang.IllegalArgumentException- if the array contains a null element
-
noNullElements
public static void noNullElements(java.lang.Object[] objects, java.lang.String msg)Validates that the array contains no null elements- Parameters:
objects- the array to testmsg- message to include in the Exception if validation fails- Throws:
java.lang.IllegalArgumentException- if the array contains a null element
-
notEmpty
public static void notEmpty(@Nullable java.lang.String string)Validates that the string is not null and is not empty- Parameters:
string- the string to test- Throws:
java.lang.IllegalArgumentException- if the string is null or empty
-
notEmpty
public static void notEmpty(@Nullable java.lang.String string, java.lang.String msg)Validates that the string is not null and is not empty- Parameters:
string- the string to testmsg- message to include in the Exception if validation fails- Throws:
java.lang.IllegalArgumentException- if the string is null or empty
-
wtf
public static void wtf(java.lang.String msg)
Blow up if we reach an unexpected state.- Parameters:
msg- message to think about- Throws:
java.lang.IllegalStateException- if we reach this state
-
fail
public static void fail(java.lang.String msg)
Cause a failure.- Parameters:
msg- message to output.- Throws:
java.lang.IllegalStateException- if we reach this state
-
-