public class Preconditions extends Object
Utility class to validate Preconditions
Modifier and Type | Method and Description |
---|---|
static void |
checkArgument(boolean condition,
String message) |
static void |
checkArgument(boolean condition,
Supplier<String> message) |
static <T> T |
checkNotNull(T reference,
String errorMessage)
Deprecated.
|
static void |
checkState(boolean condition,
String message) |
static void |
checkState(boolean condition,
Supplier<String> message) |
public static void checkArgument(boolean condition, String message)
condition
- Condition that the argument must satisfymessage
- The Message of the exception in case the condition is invalidpublic static void checkArgument(boolean condition, Supplier<String> message)
condition
- Condition that the argument must satisfymessage
- The Message supplier for the exception in case the condition is invalidpublic static void checkState(boolean condition, String message)
condition
- Condition that must be satisfiedmessage
- The Message of the exception in case the condition is invalidpublic static void checkState(boolean condition, Supplier<String> message)
condition
- Condition that must be satisfiedmessage
- The Message of the exception in case the condition is invalidmessage
- The Message supplier for the exception in case the condition is invalid@Deprecated public static <T> T checkNotNull(T reference, String errorMessage)
Objects.requireNonNull(Object, String)
reference
- an object referenceerrorMessage
- the exception message to use if the check failsNullPointerException
- if reference
is nullCopyright © 2018. All rights reserved.