public final class ExceptionUtils extends Object
Modifier and Type | Method and Description |
---|---|
static void |
throwIfNotNull(RuntimeException error)
This is a wrapper method that throws a
RuntimeException if it is not null . |
public static void throwIfNotNull(RuntimeException error)
RuntimeException
if it is not null
.
It is used to avoid the slow and expensive creation of an exception object on each checking.
For a sample usage,
throwIfNotNull(cond ? null : new RuntimeException("msg"));
It is important that we use lazy evaluation of the if
statement.error
- the error thrown if the condition is not satisfiedCopyright © 2010-2020 NM FinTech Ltd.. All Rights Reserved.