public final class Ensures extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
ensure(boolean expression)
Ensures the truth of an expression involving one or more parameters
to the calling method.
|
static void |
ensure(boolean expression,
Object message)
Ensures the truth of an expression involving one or more parameters
to the calling method.
|
static void |
ensure(boolean expression,
String fmt,
Object... args)
Ensures the truth of an expression involving one or more parameters
to the calling method.
|
static <T> T |
ensureNonNull(T obj)
Checks that the specified object reference is not
null. |
static <T> T |
ensureNonNull(T obj,
String message)
Checks that the specified object reference is not
null and
throws a customized NullPointerException if it is. |
static <T> T |
ensureNonNull(T obj,
String fmt,
Object... args)
Checks that the specified object reference is not
null and
throws a customized NullPointerException if it is. |
public static <T> T ensureNonNull(T obj)
null.T - the type of the referenceobj - the object reference to check for nullityobj if not nullNullPointerException - if obj is nullpublic static <T> T ensureNonNull(T obj,
String message)
null and
throws a customized NullPointerException if it is.T - the type of the referenceobj - the object reference to check for nullitymessage - detail message to be used in the event that a NullPointerException is thrownobj if not nullNullPointerException - if obj is nullpublic static <T> T ensureNonNull(T obj,
String fmt,
Object... args)
null and
throws a customized NullPointerException if it is.T - the type of the referenceobj - the object reference to check for nullityfmt - the exception message with format stringargs - arguments referenced by the format specifiers in the format
stringobj if not nullNullPointerException - if obj is nullpublic static void ensure(boolean expression)
expression - a boolean expressionIllegalArgumentException - if expression is falsepublic static void ensure(boolean expression,
Object message)
expression - a boolean expressionmessage - the exception message to use if the check fails;
will be converted to a string using
String.valueOf(Object)IllegalArgumentException - if expression is falsepublic static void ensure(boolean expression,
String fmt,
Object... args)
expression - a boolean expressionfmt - the exception message with format stringargs - arguments referenced by the format specifiers in the format
stringIllegalArgumentException - if expression is falseCopyright © 2023. All rights reserved.