Package com.unboundid.util
Class Validator
java.lang.Object
com.unboundid.util.Validator
This class provides a number of methods that can be used to enforce
constraints on the behavior of SDK methods.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidensureFalse(boolean condition) Ensures that the provided condition isfalse.static voidensureFalse(boolean condition, String message) Ensures that the provided condition isfalse.static voidEnsures that the provided object is notnull.static voidensureNotNull(Object o1, Object o2) Ensures that none of the provided objects isnull.static voidensureNotNull(Object o1, Object o2, Object o3) Ensures that none of the provided objects isnull.static voidensureNotNull(Object o1, Object o2, Object o3, Object o4) Ensures that none of the provided objects isnull.static voidEnsures that none of the provided objects isnull.static voidensureNotNullOrEmpty(byte[] array) Ensures that the provided array is notnulland has a length of at least one.static voidensureNotNullOrEmpty(byte[] array, String message) Ensures that the provided array is notnulland has a length of at least one.static voidensureNotNullOrEmpty(char[] array) Ensures that the provided array is notnulland has a length of at least one.static voidensureNotNullOrEmpty(char[] array, String message) Ensures that the provided array is notnulland has a length of at least one.static voidensureNotNullOrEmpty(int[] array) Ensures that the provided array is notnulland has a length of at least one.static voidensureNotNullOrEmpty(int[] array, String message) Ensures that the provided array is notnulland has a length of at least one.static voidensureNotNullOrEmpty(long[] array) Ensures that the provided array is notnulland has a length of at least one.static voidensureNotNullOrEmpty(long[] array, String message) Ensures that the provided array is notnulland has a length of at least one.static voidensureNotNullOrEmpty(CharSequence charSequence) Ensures that the provided character sequence is notnulland has a length of at least one.static voidensureNotNullOrEmpty(CharSequence charSequence, String message) Ensures that the provided character sequence is notnulland has a length of at least one.static voidensureNotNullOrEmpty(Object[] array) Ensures that the provided array is notnulland has a length of at least one.static voidensureNotNullOrEmpty(Object[] array, String message) Ensures that the provided array is notnulland has a length of at least one.static voidensureNotNullOrEmpty(Collection<?> collection) Ensures that the provided collection is notnulland contains at least one item.static voidensureNotNullOrEmpty(Collection<?> collection, String message) Ensures that the provided collection is notnulland contains at least one item.static voidensureNotNullOrEmpty(Map<?, ?> map) Ensures that the provided map is notnulland contains at least one item.static voidensureNotNullOrEmpty(Map<?, ?> map, String message) Ensures that the provided map is notnulland contains at least one item.static voidensureNotNullWithMessage(Object o, String message) Ensures that the provided object is notnull.static voidensureTrue(boolean condition) Ensures that the provided condition istrue.static voidensureTrue(boolean condition, String message) Ensures that the provided condition istrue.static voidIndicates that an expected condition was not true by throwing anLDAPSDKUsageExceptionwith the provided information.static voidIndicates that an expected condition was not true by throwing anLDAPSDKUsageExceptionwith the provided information.
-
Method Details
-
ensureNotNull
Ensures that the provided object is notnull.- Parameters:
o- The object to examine.- Throws:
LDAPSDKUsageException- If the provided object isnull.
-
ensureNotNullWithMessage
public static void ensureNotNullWithMessage(@Nullable Object o, @NotNull String message) throws LDAPSDKUsageException Ensures that the provided object is notnull.- Parameters:
o- The object to examine.message- The message to include in the exception thrown if the provided object isnull.- Throws:
LDAPSDKUsageException- If the provided object isnull.
-
ensureNotNull
public static void ensureNotNull(@Nullable Object o1, @Nullable Object o2) throws LDAPSDKUsageException Ensures that none of the provided objects isnull.- Parameters:
o1- The first object for which to make the determination.o2- The second object for which to make the determination.- Throws:
LDAPSDKUsageException- If any of the provided objects isnull.
-
ensureNotNull
public static void ensureNotNull(@Nullable Object o1, @Nullable Object o2, @Nullable Object o3) throws LDAPSDKUsageException Ensures that none of the provided objects isnull.- Parameters:
o1- The first object for which to make the determination.o2- The second object for which to make the determination.o3- The third object for which to make the determination.- Throws:
LDAPSDKUsageException- If any of the provided objects isnull.
-
ensureNotNull
public static void ensureNotNull(@Nullable Object o1, @Nullable Object o2, @Nullable Object o3, @Nullable Object o4) throws LDAPSDKUsageException Ensures that none of the provided objects isnull.- Parameters:
o1- The first object for which to make the determination.o2- The second object for which to make the determination.o3- The third object for which to make the determination.o4- The fourth object for which to make the determination.- Throws:
LDAPSDKUsageException- If any of the provided objects isnull.
-
ensureNotNull
public static void ensureNotNull(@Nullable Object o1, @Nullable Object o2, @Nullable Object o3, @Nullable Object o4, @Nullable Object o5) throws LDAPSDKUsageException Ensures that none of the provided objects isnull.- Parameters:
o1- The first object for which to make the determination.o2- The second object for which to make the determination.o3- The third object for which to make the determination.o4- The fourth object for which to make the determination.o5- The fifth object for which to make the determination.- Throws:
LDAPSDKUsageException- If any of the provided objects isnull.
-
ensureNotNullOrEmpty
Ensures that the provided collection is notnulland contains at least one item.- Parameters:
collection- The collection to verify.- Throws:
LDAPSDKUsageException- If the provided collection isnullor empty.
-
ensureNotNullOrEmpty
public static void ensureNotNullOrEmpty(@Nullable Collection<?> collection, @NotNull String message) Ensures that the provided collection is notnulland contains at least one item.- Parameters:
collection- The collection to verify.message- The message to include in the exception thrown if the provided collection isnullor empty.- Throws:
LDAPSDKUsageException- If the provided collection isnullor empty.
-
ensureNotNullOrEmpty
Ensures that the provided map is notnulland contains at least one item.- Parameters:
map- The map to verify.- Throws:
LDAPSDKUsageException- If the provided map isnullor empty.
-
ensureNotNullOrEmpty
Ensures that the provided map is notnulland contains at least one item.- Parameters:
map- The map to verify.message- The message to include in the exception thrown if the provided map isnullor empty.- Throws:
LDAPSDKUsageException- If the provided map isnullor empty.
-
ensureNotNullOrEmpty
Ensures that the provided array is notnulland has a length of at least one.- Parameters:
array- The array to verify.- Throws:
LDAPSDKUsageException- If the provided array isnullor empty.
-
ensureNotNullOrEmpty
Ensures that the provided array is notnulland has a length of at least one.- Parameters:
array- The array to verify.message- The message to include in the exception thrown if the provided array isnullor empty.- Throws:
LDAPSDKUsageException- If the provided array isnullor empty.
-
ensureNotNullOrEmpty
Ensures that the provided array is notnulland has a length of at least one.- Parameters:
array- The array to verify.- Throws:
LDAPSDKUsageException- If the provided array isnullor empty.
-
ensureNotNullOrEmpty
Ensures that the provided array is notnulland has a length of at least one.- Parameters:
array- The array to verify.message- The message to include in the exception thrown if the provided array isnullor empty.- Throws:
LDAPSDKUsageException- If the provided array isnullor empty.
-
ensureNotNullOrEmpty
Ensures that the provided array is notnulland has a length of at least one.- Parameters:
array- The array to verify.- Throws:
LDAPSDKUsageException- If the provided array isnullor empty.
-
ensureNotNullOrEmpty
Ensures that the provided array is notnulland has a length of at least one.- Parameters:
array- The array to verify.message- The message to include in the exception thrown if the provided array isnullor empty.- Throws:
LDAPSDKUsageException- If the provided array isnullor empty.
-
ensureNotNullOrEmpty
Ensures that the provided array is notnulland has a length of at least one.- Parameters:
array- The array to verify.- Throws:
LDAPSDKUsageException- If the provided array isnullor empty.
-
ensureNotNullOrEmpty
Ensures that the provided array is notnulland has a length of at least one.- Parameters:
array- The array to verify.message- The message to include in the exception thrown if the provided array isnullor empty.- Throws:
LDAPSDKUsageException- If the provided array isnullor empty.
-
ensureNotNullOrEmpty
Ensures that the provided array is notnulland has a length of at least one.- Parameters:
array- The array to verify.- Throws:
LDAPSDKUsageException- If the provided array isnullor empty.
-
ensureNotNullOrEmpty
Ensures that the provided array is notnulland has a length of at least one.- Parameters:
array- The array to verify.message- The message to include in the exception thrown if the provided array isnullor empty.- Throws:
LDAPSDKUsageException- If the provided array isnullor empty.
-
ensureNotNullOrEmpty
Ensures that the provided character sequence is notnulland has a length of at least one.- Parameters:
charSequence- The character sequence to verify.- Throws:
LDAPSDKUsageException- If the provided character sequence isnullor empty.
-
ensureNotNullOrEmpty
public static void ensureNotNullOrEmpty(@Nullable CharSequence charSequence, @NotNull String message) Ensures that the provided character sequence is notnulland has a length of at least one.- Parameters:
charSequence- The character sequence to verify.message- The message to include in the exception thrown if the provided character sequence isnullor empty.- Throws:
LDAPSDKUsageException- If the provided character sequence isnullor empty.
-
ensureTrue
Ensures that the provided condition istrue.- Parameters:
condition- The condition to verify.- Throws:
LDAPSDKUsageException- If the provided condition isfalse.
-
ensureTrue
public static void ensureTrue(boolean condition, @NotNull String message) throws LDAPSDKUsageException Ensures that the provided condition istrue.- Parameters:
condition- The condition to verify.message- The message to include in the exception thrown if the provided object isnull.- Throws:
LDAPSDKUsageException- If the provided condition isfalse.
-
ensureFalse
Ensures that the provided condition isfalse.- Parameters:
condition- The condition to verify.- Throws:
LDAPSDKUsageException- If the provided condition istrue.
-
ensureFalse
public static void ensureFalse(boolean condition, @NotNull String message) throws LDAPSDKUsageException Ensures that the provided condition isfalse.- Parameters:
condition- The condition to verify.message- The message to include in the exception thrown if the provided object isnull.- Throws:
LDAPSDKUsageException- If the provided condition istrue.
-
violation
Indicates that an expected condition was not true by throwing anLDAPSDKUsageExceptionwith the provided information.- Parameters:
message- The message to use for the resulting exception. It must not benull.- Throws:
LDAPSDKUsageException- To indicate that a violation occurred.
-
violation
public static void violation(@NotNull String message, @Nullable Throwable cause) throws LDAPSDKUsageException Indicates that an expected condition was not true by throwing anLDAPSDKUsageExceptionwith the provided information.- Parameters:
message- The message to use for the resulting exception. It must not benull.cause- The exception that triggered the violation. It may benullif there is no associated exception.- Throws:
LDAPSDKUsageException- To indicate that a violation occurred.
-