public final class Validate extends Object
It provides consistent message strings for frequently encountered checks. That simplifies callers because they have to supply only the name of the argument that failed a check instead of having to supply the entire message.
| Modifier and Type | Method and Description |
|---|---|
static void |
checkArgument(boolean expression,
String format,
Object... args) |
static void |
checkGreater(long value1,
String value1Name,
long value2,
String value2Name)
Validates that the first value is greater than the second value.
|
static void |
checkGreaterOrEqual(long value1,
String value1Name,
long value2,
String value2Name)
Validates that the first value is greater than or equal to the second value.
|
static void |
checkIntegerMultiple(long value1,
String value1Name,
long value2,
String value2Name)
Validates that the first value is an integer multiple of the second value.
|
static void |
checkLessOrEqual(long value1,
String value1Name,
long value2,
String value2Name)
Validates that the first value is less than or equal to the second value.
|
static void |
checkNotNegative(long value,
String argName)
Validates that the given integer argument is not negative.
|
static void |
checkNotNull(Object obj,
String argName)
Validates that the given reference argument is not null.
|
static void |
checkNotNullAndNotEmpty(byte[] array,
String argName)
Validates that the given array is not null and has at least one element.
|
static void |
checkNotNullAndNotEmpty(int[] array,
String argName)
Validates that the given array is not null and has at least one element.
|
static <T> void |
checkNotNullAndNotEmpty(Iterable<T> iter,
String argName)
Validates that the given buffer is not null and has non-zero capacity.
|
static void |
checkNotNullAndNotEmpty(long[] array,
String argName)
Validates that the given array is not null and has at least one element.
|
static void |
checkNotNullAndNotEmpty(short[] array,
String argName)
Validates that the given array is not null and has at least one element.
|
static void |
checkNotNullAndNotEmpty(String arg,
String argName)
Validates that the given string is not null and has non-zero length.
|
static <T> void |
checkNotNullAndNotEmpty(T[] array,
String argName)
Validates that the given array is not null and has at least one element.
|
static <T> void |
checkNotNullAndNumberOfElements(Collection<T> collection,
int numElements,
String argName)
Validates that the given set is not null and has an exact number of items.
|
static void |
checkPathExists(Path path,
String argName) |
static void |
checkPathExistsAsDir(Path path,
String argName) |
static void |
checkPathExistsAsFile(Path path,
String argName) |
static void |
checkPositiveInteger(long value,
String argName)
Validates that the given integer argument is not zero or negative.
|
static void |
checkRequired(boolean isPresent,
String argName) |
static void |
checkState(boolean expression,
String format,
Object... args) |
static void |
checkValid(boolean isValid,
String argName)
Validates that the expression (that checks a field is valid) is true.
|
static void |
checkValid(boolean isValid,
String argName,
String validValues)
Validates that the expression (that checks a field is valid) is true.
|
static void |
checkValuesEqual(long value1,
String value1Name,
long value2,
String value2Name)
Validates that the given two values are equal.
|
static void |
checkWithinRange(double value,
String valueName,
double minValueInclusive,
double maxValueInclusive)
Validates that the given value is within the given range of values.
|
static void |
checkWithinRange(long value,
String valueName,
long minValueInclusive,
long maxValueInclusive)
Validates that the given value is within the given range of values.
|
public static void checkNotNull(Object obj, String argName)
public static void checkPositiveInteger(long value,
String argName)
public static void checkNotNegative(long value,
String argName)
public static void checkRequired(boolean isPresent,
String argName)
public static void checkValid(boolean isValid,
String argName)
public static void checkValid(boolean isValid,
String argName,
String validValues)
public static void checkNotNullAndNotEmpty(String arg, String argName)
public static <T> void checkNotNullAndNotEmpty(T[] array,
String argName)
public static void checkNotNullAndNotEmpty(byte[] array,
String argName)
public static void checkNotNullAndNotEmpty(short[] array,
String argName)
public static void checkNotNullAndNotEmpty(int[] array,
String argName)
public static void checkNotNullAndNotEmpty(long[] array,
String argName)
public static <T> void checkNotNullAndNotEmpty(Iterable<T> iter, String argName)
public static <T> void checkNotNullAndNumberOfElements(Collection<T> collection, int numElements, String argName)
public static void checkValuesEqual(long value1,
String value1Name,
long value2,
String value2Name)
public static void checkIntegerMultiple(long value1,
String value1Name,
long value2,
String value2Name)
public static void checkGreater(long value1,
String value1Name,
long value2,
String value2Name)
public static void checkGreaterOrEqual(long value1,
String value1Name,
long value2,
String value2Name)
public static void checkLessOrEqual(long value1,
String value1Name,
long value2,
String value2Name)
public static void checkWithinRange(long value,
String valueName,
long minValueInclusive,
long maxValueInclusive)
public static void checkWithinRange(double value,
String valueName,
double minValueInclusive,
double maxValueInclusive)
Copyright © 2022 The Apache Software Foundation. All rights reserved.