Package com.unboundid.util
Class Validator
- java.lang.Object
-
- com.unboundid.util.Validator
-
@ThreadSafety(level=COMPLETELY_THREADSAFE) public final class Validator extends java.lang.Object
This class provides a number of methods that can be used to enforce constraints on the behavior of SDK methods.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
ensureFalse(boolean condition)
Ensures that the provided condition isfalse
.static void
ensureFalse(boolean condition, java.lang.String message)
Ensures that the provided condition isfalse
.static void
ensureNotNull(java.lang.Object o)
Ensures that the provided object is notnull
.static void
ensureNotNull(java.lang.Object o1, java.lang.Object o2)
Ensures that none of the provided objects isnull
.static void
ensureNotNull(java.lang.Object o1, java.lang.Object o2, java.lang.Object o3)
Ensures that none of the provided objects isnull
.static void
ensureNotNull(java.lang.Object o1, java.lang.Object o2, java.lang.Object o3, java.lang.Object o4)
Ensures that none of the provided objects isnull
.static void
ensureNotNull(java.lang.Object o1, java.lang.Object o2, java.lang.Object o3, java.lang.Object o4, java.lang.Object o5)
Ensures that none of the provided objects isnull
.static void
ensureNotNullOrEmpty(byte[] array)
Ensures that the provided array is notnull
and has a length of at least one.static void
ensureNotNullOrEmpty(byte[] array, java.lang.String message)
Ensures that the provided array is notnull
and has a length of at least one.static void
ensureNotNullOrEmpty(char[] array)
Ensures that the provided array is notnull
and has a length of at least one.static void
ensureNotNullOrEmpty(char[] array, java.lang.String message)
Ensures that the provided array is notnull
and has a length of at least one.static void
ensureNotNullOrEmpty(int[] array)
Ensures that the provided array is notnull
and has a length of at least one.static void
ensureNotNullOrEmpty(int[] array, java.lang.String message)
Ensures that the provided array is notnull
and has a length of at least one.static void
ensureNotNullOrEmpty(long[] array)
Ensures that the provided array is notnull
and has a length of at least one.static void
ensureNotNullOrEmpty(long[] array, java.lang.String message)
Ensures that the provided array is notnull
and has a length of at least one.static void
ensureNotNullOrEmpty(java.lang.CharSequence charSequence)
Ensures that the provided character sequence is notnull
and has a length of at least one.static void
ensureNotNullOrEmpty(java.lang.CharSequence charSequence, java.lang.String message)
Ensures that the provided character sequence is notnull
and has a length of at least one.static void
ensureNotNullOrEmpty(java.lang.Object[] array)
Ensures that the provided array is notnull
and has a length of at least one.static void
ensureNotNullOrEmpty(java.lang.Object[] array, java.lang.String message)
Ensures that the provided array is notnull
and has a length of at least one.static void
ensureNotNullOrEmpty(java.util.Collection<?> collection)
Ensures that the provided collection is notnull
and contains at least one item.static void
ensureNotNullOrEmpty(java.util.Collection<?> collection, java.lang.String message)
Ensures that the provided collection is notnull
and contains at least one item.static void
ensureNotNullOrEmpty(java.util.Map<?,?> map)
Ensures that the provided map is notnull
and contains at least one item.static void
ensureNotNullOrEmpty(java.util.Map<?,?> map, java.lang.String message)
Ensures that the provided map is notnull
and contains at least one item.static void
ensureNotNullWithMessage(java.lang.Object o, java.lang.String message)
Ensures that the provided object is notnull
.static void
ensureTrue(boolean condition)
Ensures that the provided condition istrue
.static void
ensureTrue(boolean condition, java.lang.String message)
Ensures that the provided condition istrue
.static void
violation(java.lang.String message)
Indicates that an expected condition was not true by throwing anLDAPSDKUsageException
with the provided information.static void
violation(java.lang.String message, java.lang.Throwable cause)
Indicates that an expected condition was not true by throwing anLDAPSDKUsageException
with the provided information.
-
-
-
Method Detail
-
ensureNotNull
public static void ensureNotNull(java.lang.Object o) throws LDAPSDKUsageException
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(java.lang.Object o, java.lang.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(java.lang.Object o1, java.lang.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(java.lang.Object o1, java.lang.Object o2, java.lang.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(java.lang.Object o1, java.lang.Object o2, java.lang.Object o3, java.lang.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(java.lang.Object o1, java.lang.Object o2, java.lang.Object o3, java.lang.Object o4, java.lang.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
public static void ensureNotNullOrEmpty(java.util.Collection<?> collection)
Ensures that the provided collection is notnull
and contains at least one item.- Parameters:
collection
- The collection to verify.- Throws:
LDAPSDKUsageException
- If the provided collection isnull
or empty.
-
ensureNotNullOrEmpty
public static void ensureNotNullOrEmpty(java.util.Collection<?> collection, java.lang.String message)
Ensures that the provided collection is notnull
and contains at least one item.- Parameters:
collection
- The collection to verify.message
- The message to include in the exception thrown if the provided collection isnull
or empty.- Throws:
LDAPSDKUsageException
- If the provided collection isnull
or empty.
-
ensureNotNullOrEmpty
public static void ensureNotNullOrEmpty(java.util.Map<?,?> map)
Ensures that the provided map is notnull
and contains at least one item.- Parameters:
map
- The map to verify.- Throws:
LDAPSDKUsageException
- If the provided map isnull
or empty.
-
ensureNotNullOrEmpty
public static void ensureNotNullOrEmpty(java.util.Map<?,?> map, java.lang.String message)
Ensures that the provided map is notnull
and contains at least one item.- Parameters:
map
- The map to verify.message
- The message to include in the exception thrown if the provided map isnull
or empty.- Throws:
LDAPSDKUsageException
- If the provided map isnull
or empty.
-
ensureNotNullOrEmpty
public static void ensureNotNullOrEmpty(java.lang.Object[] array)
Ensures that the provided array is notnull
and has a length of at least one.- Parameters:
array
- The array to verify.- Throws:
LDAPSDKUsageException
- If the provided array isnull
or empty.
-
ensureNotNullOrEmpty
public static void ensureNotNullOrEmpty(java.lang.Object[] array, java.lang.String message)
Ensures that the provided array is notnull
and 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 isnull
or empty.- Throws:
LDAPSDKUsageException
- If the provided array isnull
or empty.
-
ensureNotNullOrEmpty
public static void ensureNotNullOrEmpty(byte[] array)
Ensures that the provided array is notnull
and has a length of at least one.- Parameters:
array
- The array to verify.- Throws:
LDAPSDKUsageException
- If the provided array isnull
or empty.
-
ensureNotNullOrEmpty
public static void ensureNotNullOrEmpty(byte[] array, java.lang.String message)
Ensures that the provided array is notnull
and 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 isnull
or empty.- Throws:
LDAPSDKUsageException
- If the provided array isnull
or empty.
-
ensureNotNullOrEmpty
public static void ensureNotNullOrEmpty(char[] array)
Ensures that the provided array is notnull
and has a length of at least one.- Parameters:
array
- The array to verify.- Throws:
LDAPSDKUsageException
- If the provided array isnull
or empty.
-
ensureNotNullOrEmpty
public static void ensureNotNullOrEmpty(char[] array, java.lang.String message)
Ensures that the provided array is notnull
and 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 isnull
or empty.- Throws:
LDAPSDKUsageException
- If the provided array isnull
or empty.
-
ensureNotNullOrEmpty
public static void ensureNotNullOrEmpty(int[] array)
Ensures that the provided array is notnull
and has a length of at least one.- Parameters:
array
- The array to verify.- Throws:
LDAPSDKUsageException
- If the provided array isnull
or empty.
-
ensureNotNullOrEmpty
public static void ensureNotNullOrEmpty(int[] array, java.lang.String message)
Ensures that the provided array is notnull
and 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 isnull
or empty.- Throws:
LDAPSDKUsageException
- If the provided array isnull
or empty.
-
ensureNotNullOrEmpty
public static void ensureNotNullOrEmpty(long[] array)
Ensures that the provided array is notnull
and has a length of at least one.- Parameters:
array
- The array to verify.- Throws:
LDAPSDKUsageException
- If the provided array isnull
or empty.
-
ensureNotNullOrEmpty
public static void ensureNotNullOrEmpty(long[] array, java.lang.String message)
Ensures that the provided array is notnull
and 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 isnull
or empty.- Throws:
LDAPSDKUsageException
- If the provided array isnull
or empty.
-
ensureNotNullOrEmpty
public static void ensureNotNullOrEmpty(java.lang.CharSequence charSequence)
Ensures that the provided character sequence is notnull
and has a length of at least one.- Parameters:
charSequence
- The character sequence to verify.- Throws:
LDAPSDKUsageException
- If the provided character sequence isnull
or empty.
-
ensureNotNullOrEmpty
public static void ensureNotNullOrEmpty(java.lang.CharSequence charSequence, java.lang.String message)
Ensures that the provided character sequence is notnull
and 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 isnull
or empty.- Throws:
LDAPSDKUsageException
- If the provided character sequence isnull
or empty.
-
ensureTrue
public static void ensureTrue(boolean condition) throws LDAPSDKUsageException
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, java.lang.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
public static void ensureFalse(boolean condition) throws LDAPSDKUsageException
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, java.lang.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
public static void violation(java.lang.String message) throws LDAPSDKUsageException
Indicates that an expected condition was not true by throwing anLDAPSDKUsageException
with 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(java.lang.String message, java.lang.Throwable cause) throws LDAPSDKUsageException
Indicates that an expected condition was not true by throwing anLDAPSDKUsageException
with 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 benull
if there is no associated exception.- Throws:
LDAPSDKUsageException
- To indicate that a violation occurred.
-
-