Package com.ibm.cloud.sdk.core.util
Class Validator
- java.lang.Object
-
- com.ibm.cloud.sdk.core.util.Validator
-
public final class Validator extends java.lang.ObjectThis class assists in validating arguments.
If an argument value is deemed invalid, an IllegalArgumentException is thrown.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidisNull(java.lang.Object object, java.lang.String message)Validates that the specified argument isnull; otherwise throwing an exception with the specified message.static voidisTrue(boolean expression, java.lang.String message)Validates that the argument condition istrue; otherwise throwing an exception with the specified message.static voidnotEmpty(java.lang.Object[] array, java.lang.String message)Validates that the specified argument array is neithernullnor a length of zero (no elements); otherwise throwing an exception with the specified message.static voidnotEmpty(java.lang.String string, java.lang.String message)Validator that the specified argument string is neithernullnor a length of zero (no characters); otherwise throwing an exception with the specified message.static voidnotEmpty(java.util.Collection collection, java.lang.String message)Validates that the specified argument collection is neithernullnor a size of zero (no elements); otherwise throwing an exception with the specified message.static voidnotNull(java.lang.Object object, java.lang.String message)Validates that the specified argument is notnull; otherwise throwing an exception with the specified message.
-
-
-
Method Detail
-
isTrue
public static void isTrue(boolean expression, java.lang.String message)Validates that the argument condition istrue; otherwise throwing an exception with the specified message. This method is useful when validating according to an arbitrary boolean expression, such as validating a primitive number or using your own custom validation expression.- Parameters:
expression- the boolean expression to checkmessage- the exception message if invalid- Throws:
java.lang.IllegalArgumentException- if expression isfalse
-
notEmpty
public static void notEmpty(java.util.Collection collection, java.lang.String message)Validates that the specified argument collection is neithernullnor a size of zero (no elements); otherwise throwing an exception with the specified message.- Parameters:
collection- the collection to checkmessage- the exception message if invalid- Throws:
java.lang.IllegalArgumentException- if the collection is empty
-
notEmpty
public static void notEmpty(java.lang.Object[] array, java.lang.String message)Validates that the specified argument array is neithernullnor a length of zero (no elements); otherwise throwing an exception with the specified message.- Parameters:
array- the array to checkmessage- the exception message if invalid- Throws:
java.lang.IllegalArgumentException- if the array is empty
-
notEmpty
public static void notEmpty(java.lang.String string, java.lang.String message)Validator that the specified argument string is neithernullnor a length of zero (no characters); otherwise throwing an exception with the specified message.- Parameters:
string- the string to checkmessage- the exception message if invalid- Throws:
java.lang.IllegalArgumentException- if the string is empty
-
notNull
public static void notNull(java.lang.Object object, java.lang.String message)Validates that the specified argument is notnull; otherwise throwing an exception with the specified message.- Parameters:
object- the object to checkmessage- the exception message if invalid
-
isNull
public static void isNull(java.lang.Object object, java.lang.String message)Validates that the specified argument isnull; otherwise throwing an exception with the specified message.- Parameters:
object- the object to checkmessage- the exception message if invalid
-
-