Class Validate
java.lang.Object
org.apache.hadoop.fs.impl.prefetch.Validate
A superset of Validate class in Apache commons lang3.
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.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidcheckGreater(long value1, String value1Name, long value2, String value2Name) Validates that the first value is greater than the second value.static voidcheckGreaterOrEqual(long value1, String value1Name, long value2, String value2Name) Validates that the first value is greater than or equal to the second value.static voidcheckIntegerMultiple(long value1, String value1Name, long value2, String value2Name) Validates that the first value is an integer multiple of the second value.static voidcheckLessOrEqual(long value1, String value1Name, long value2, String value2Name) Validates that the first value is less than or equal to the second value.static voidcheckNotNegative(long value, String argName) Validates that the given integer argument is not negative.static voidcheckNotNull(Object obj, String argName) Validates that the given reference argument is not null.static voidcheckNotNullAndNotEmpty(byte[] array, String argName) Validates that the given array is not null and has at least one element.static voidcheckNotNullAndNotEmpty(int[] array, String argName) Validates that the given array is not null and has at least one element.static voidcheckNotNullAndNotEmpty(long[] array, String argName) Validates that the given array is not null and has at least one element.static voidcheckNotNullAndNotEmpty(short[] array, String argName) Validates that the given array is not null and has at least one element.static <T> voidcheckNotNullAndNotEmpty(Iterable<T> iter, String argName) Validates that the given buffer is not null and has non-zero capacity.static voidcheckNotNullAndNotEmpty(String arg, String argName) Validates that the given string is not null and has non-zero length.static <T> voidcheckNotNullAndNotEmpty(T[] array, String argName) Validates that the given array is not null and has at least one element.static <T> voidcheckNotNullAndNumberOfElements(Collection<T> collection, int numElements, String argName) Validates that the given set is not null and has an exact number of items.static voidcheckPathExists(Path path, String argName) Validates that the given path exists.static voidcheckPathExistsAsDir(Path path, String argName) Validates that the given path exists and is a directory.static voidcheckPathExistsAsFile(Path path, String argName) Validates that the given path exists and is a file.static voidcheckPositiveInteger(long value, String argName) Validates that the given integer argument is not zero or negative.static voidcheckRequired(boolean isPresent, String argName) Validates that the expression (that checks a required field is present) is true.static voidcheckState(boolean expression, String format, Object... args) Check state.static voidcheckValid(boolean isValid, String argName) Validates that the expression (that checks a field is valid) is true.static voidcheckValid(boolean isValid, String argName, String validValues) Validates that the expression (that checks a field is valid) is true.static voidcheckValuesEqual(long value1, String value1Name, long value2, String value2Name) Validates that the given two values are equal.static voidcheckWithinRange(double value, String valueName, double minValueInclusive, double maxValueInclusive) Validates that the given value is within the given range of values.static voidcheckWithinRange(long value, String valueName, long minValueInclusive, long maxValueInclusive) Validates that the given value is within the given range of values.
-
Method Details
-
checkNotNull
Validates that the given reference argument is not null.- Parameters:
obj- the argument reference to validate.argName- the name of the argument being validated.
-
checkPositiveInteger
Validates that the given integer argument is not zero or negative.- Parameters:
value- the argument value to validateargName- the name of the argument being validated.
-
checkNotNegative
Validates that the given integer argument is not negative.- Parameters:
value- the argument value to validateargName- the name of the argument being validated.
-
checkRequired
Validates that the expression (that checks a required field is present) is true.- Parameters:
isPresent- indicates whether the given argument is present.argName- the name of the argument being validated.
-
checkValid
Validates that the expression (that checks a field is valid) is true.- Parameters:
isValid- indicates whether the given argument is valid.argName- the name of the argument being validated.
-
checkValid
Validates that the expression (that checks a field is valid) is true.- Parameters:
isValid- indicates whether the given argument is valid.argName- the name of the argument being validated.validValues- the list of values that are allowed.
-
checkNotNullAndNotEmpty
Validates that the given string is not null and has non-zero length.- Parameters:
arg- the argument reference to validate.argName- the name of the argument being validated.
-
checkNotNullAndNotEmpty
Validates that the given array is not null and has at least one element.- Type Parameters:
T- the type of array's elements.- Parameters:
array- the argument reference to validate.argName- the name of the argument being validated.
-
checkNotNullAndNotEmpty
Validates that the given array is not null and has at least one element.- Parameters:
array- the argument reference to validate.argName- the name of the argument being validated.
-
checkNotNullAndNotEmpty
Validates that the given array is not null and has at least one element.- Parameters:
array- the argument reference to validate.argName- the name of the argument being validated.
-
checkNotNullAndNotEmpty
Validates that the given array is not null and has at least one element.- Parameters:
array- the argument reference to validate.argName- the name of the argument being validated.
-
checkNotNullAndNotEmpty
Validates that the given array is not null and has at least one element.- Parameters:
array- the argument reference to validate.argName- the name of the argument being validated.
-
checkNotNullAndNotEmpty
Validates that the given buffer is not null and has non-zero capacity.- Type Parameters:
T- the type of iterable's elements.- Parameters:
iter- the argument reference to validate.argName- the name of the argument being validated.
-
checkNotNullAndNumberOfElements
public 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.- Type Parameters:
T- the type of collection's elements.- Parameters:
collection- the argument reference to validate.numElements- the expected number of elements in the collection.argName- the name of the argument being validated.
-
checkValuesEqual
Validates that the given two values are equal.- Parameters:
value1- the first value to check.value1Name- the name of the first argument.value2- the second value to check.value2Name- the name of the second argument.
-
checkIntegerMultiple
public static void checkIntegerMultiple(long value1, String value1Name, long value2, String value2Name) Validates that the first value is an integer multiple of the second value.- Parameters:
value1- the first value to check.value1Name- the name of the first argument.value2- the second value to check.value2Name- the name of the second argument.
-
checkGreater
Validates that the first value is greater than the second value.- Parameters:
value1- the first value to check.value1Name- the name of the first argument.value2- the second value to check.value2Name- the name of the second argument.
-
checkGreaterOrEqual
public 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.- Parameters:
value1- the first value to check.value1Name- the name of the first argument.value2- the second value to check.value2Name- the name of the second argument.
-
checkLessOrEqual
Validates that the first value is less than or equal to the second value.- Parameters:
value1- the first value to check.value1Name- the name of the first argument.value2- the second value to check.value2Name- the name of the second argument.
-
checkWithinRange
public static void checkWithinRange(long value, String valueName, long minValueInclusive, long maxValueInclusive) Validates that the given value is within the given range of values.- Parameters:
value- the value to check.valueName- the name of the argument.minValueInclusive- inclusive lower limit for the value.maxValueInclusive- inclusive upper limit for the value.
-
checkWithinRange
public static void checkWithinRange(double value, String valueName, double minValueInclusive, double maxValueInclusive) Validates that the given value is within the given range of values.- Parameters:
value- the value to check.valueName- the name of the argument.minValueInclusive- inclusive lower limit for the value.maxValueInclusive- inclusive upper limit for the value.
-
checkPathExists
Validates that the given path exists.- Parameters:
path- the path to check.argName- the name of the argument being validated.
-
checkPathExistsAsDir
Validates that the given path exists and is a directory.- Parameters:
path- the path to check.argName- the name of the argument being validated.
-
checkPathExistsAsFile
Validates that the given path exists and is a file.- Parameters:
path- the path to check.argName- the name of the argument being validated.
-
checkState
Check state.- Parameters:
expression- expression which must hold.format- format stringargs- arguments for the error string- Throws:
IllegalStateException- if the state is not valid.
-