Package app.babylon.lang
Class ArgumentCheck
java.lang.Object
app.babylon.lang.ArgumentCheck
Small argument validation helpers used throughout the library.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringRequires a non-empty string.static <T extends Collection<?>>
TnonEmpty(T c) Requires a non-empty collection.static <T> T[]nonEmpty(T[] x) Requires a non-empty array.static intnonNegative(int i) Requires a non-negative integer.static <T> TnonNull(T o) Requires a non-null reference.static <T> TRequires a non-null reference with a custom error message.
-
Method Details
-
nonNegative
public static int nonNegative(int i) Requires a non-negative integer.- Parameters:
i- value to validate- Returns:
- the supplied value
-
nonEmpty
public static <T> T[] nonEmpty(T[] x) Requires a non-empty array.- Type Parameters:
T- array element type- Parameters:
x- array to validate- Returns:
- the supplied array
-
nonEmpty
Requires a non-empty collection.- Type Parameters:
T- collection type- Parameters:
c- collection to validate- Returns:
- the supplied collection
-
nonEmpty
Requires a non-empty string.- Parameters:
s- string to validate- Returns:
- the supplied string
-
nonNull
public static <T> T nonNull(T o) Requires a non-null reference.- Type Parameters:
T- object type- Parameters:
o- object to validate- Returns:
- the supplied object
-
nonNull
Requires a non-null reference with a custom error message.- Type Parameters:
T- object type- Parameters:
o- object to validatemessage- null failure message- Returns:
- the supplied object
-