public final class Preconditions extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
checkArgument(boolean isValid,
String message)
Precondition-style validation that throws
IllegalArgumentException. |
static void |
checkArgument(boolean isValid,
String message,
Object... args)
Precondition-style validation that throws
IllegalArgumentException. |
static <T> T |
checkNotNull(T o,
String name) |
static void |
checkState(boolean isValid,
String message)
Precondition-style validation that throws
IllegalStateException. |
static void |
checkState(boolean isValid,
String message,
Object... args)
Precondition-style validation that throws
IllegalStateException. |
public static <T> T checkNotNull(T o,
String name)
throws NullPointerException
T - the type of the objecto - the param to checkname - the name of the param for the error messageNullPointerException - if o is nullpublic static void checkArgument(boolean isValid,
String message)
throws IllegalArgumentException
IllegalArgumentException.isValid - true if valid, false if an exception should be
thrownmessage - A String message for the exception.IllegalArgumentException - if isValid is falsepublic static void checkArgument(boolean isValid,
String message,
Object... args)
throws IllegalArgumentException
IllegalArgumentException.isValid - true if valid, false if an exception should be
thrownmessage - A String message for the exception.args - Objects used to fill in %s placeholders in the messageIllegalArgumentException - if isValid is falsepublic static void checkState(boolean isValid,
String message)
throws IllegalStateException
IllegalStateException.isValid - true if valid, false if an exception should be
thrownmessage - A String message for the exception.IllegalStateException - if isValid is falsepublic static void checkState(boolean isValid,
String message,
Object... args)
throws IllegalStateException
IllegalStateException.isValid - true if valid, false if an exception should be
thrownmessage - A String message for the exception.args - Objects used to fill in %s placeholders in the messageIllegalStateException - if isValid is falseCopyright © 2018 The Apache Software Foundation. All rights reserved.