Package org.luwrain.core
Class NullCheck
java.lang.Object
org.luwrain.core.NullCheck
Simplifies checking of objects validity. This class provides a set of
static methods which take care of checking the given data and throw
corresponding exceptions. All method are rather short and purposed
only for making code more readable and self-documented.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidChecks that given reference isn't null andobj.toString.isEmpty()returns false.static voidnotEmptyArray(Object[] items, String name) Checks that the array reference isn't null and the array has at least one item.static voidnotEmptyItems(Object[] items, String name) Checks that the array reference isn't null anditems[i].toString().isEmpt ()returns false for all items (if there are any).static voidChecks that provided reference isn't null.static voidnotNullItems(Object[] items, String name) Checks that the array reference isn't null and none of its items are null (if there are any).
-
Constructor Details
-
NullCheck
public NullCheck()
-
-
Method Details
-
notNull
Checks that provided reference isn't null.- Parameters:
obj- The reference to checkname- The reference name to construct better exception message- Throws:
NullPointerException
-
notEmpty
Checks that given reference isn't null andobj.toString.isEmpty()returns false.- Parameters:
obj- The reference to checkname- The reference name to construct better exception message- Throws:
NullPointerException- IllegalArgumentException
-
notNullItems
Checks that the array reference isn't null and none of its items are null (if there are any).- Parameters:
items- The reference to an array to checkname- The reference name to construct better exception message- Throws:
NullPointerException
-
notEmptyItems
Checks that the array reference isn't null anditems[i].toString().isEmpt ()returns false for all items (if there are any).- Parameters:
items- The reference to an array to checkname- The reference name to construct better exception message- Throws:
NullPointerException- IllegalArgumentException
-
notEmptyArray
Checks that the array reference isn't null and the array has at least one item.- Parameters:
items- The reference to an array to checkname- The reference name to construct better exception message- Throws:
NullPointerException- IllegalArgumentException
-