public class PreconditionsUtil
extends java.lang.Object
| Constructor and Description |
|---|
PreconditionsUtil() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
isNotNull(java.lang.Object value)
Precondition used to assert that the given value is not null.
|
static void |
throwOrLog(java.lang.Throwable exception)
Throw a runtime exception and log if the SDK runs in debug mode, or just log otherwise
|
public static void throwOrLog(@NonNull
java.lang.Throwable exception)
public static boolean isNotNull(java.lang.Object value)
If the SDK is in debug mode, a NullPointerException is thrown to indicate that the
given value is null and violates this precondition. In release mode, only a warning is logged.
So you should not assume that the verified value is non null after this call.
This returns true if the given value is, as expected, not null, else it returns
false. Hence you can use this method in a if condition to assume the non
nullability in the if block:
Foo bar = foobar();
if (PreconditionsUtil.isNotNull(bar)) {
bar.baz(); // Safe, bar is not null here
}
value - value to test the nullabilitytrue if given value is not null