The exitIfNull
Check
The exitIfNull
check is self-explanatory - it exits if a provided object is null.
Using this can reduce boilerplate code and can reduce the amount of lines a simple action like this takes.
You can go from writing:
if (object == null) throw new RuntimeException("Null-check failed!");
To writing:
// Passing only an object will already set "Null-check failed!" as the failure message!
Checks.exitIfNull(object);
// Passing a failure message is optional, but useful if you need to let the user know which check failed.
Checks.exitIfNull(object, "Token cannot be null");
Last updated on February 15, 2023