public class Preconditions
extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
checkArgument(boolean isValid)
Precondition-style validation that throws
IllegalArgumentException. |
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 void |
checkState(boolean expression,
String errorMessage)
Ensures the truth of an expression involving the state of the calling instance.
|
public static void checkArgument(boolean isValid)
throws IllegalArgumentException
IllegalArgumentException.isValid - true if valid, false if an exception should be thrownIllegalArgumentException - if isValid is falsepublic 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 expression,
String errorMessage)
expression - a boolean expressionerrorMessage - the exception message to use if the check failsIllegalStateException - if expression is false