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 Details

    • ensureNotNull

      public static void ensureNotNull(@Nullable Object o) throws LDAPSDKUsageException
      Ensures that the provided object is not null.
      Parameters:
      o - The object to examine.
      Throws:
      LDAPSDKUsageException - If the provided object is null.
    • ensureNotNullWithMessage

      Ensures that the provided object is not null.
      Parameters:
      o - The object to examine.
      message - The message to include in the exception thrown if the provided object is null.
      Throws:
      LDAPSDKUsageException - If the provided object is null.
    • ensureNotNull

      public static void ensureNotNull(@Nullable Object o1, @Nullable Object o2) throws LDAPSDKUsageException
      Ensures that none of the provided objects is null.
      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 is null.
    • ensureNotNull

      Ensures that none of the provided objects is null.
      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 is null.
    • ensureNotNull

      Ensures that none of the provided objects is null.
      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 is null.
    • ensureNotNull

      Ensures that none of the provided objects is null.
      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 is null.
    • ensureNotNullOrEmpty

      public static void ensureNotNullOrEmpty(@Nullable Collection<?> collection)
      Ensures that the provided collection is not null and contains at least one item.
      Parameters:
      collection - The collection to verify.
      Throws:
      LDAPSDKUsageException - If the provided collection is null or empty.
    • ensureNotNullOrEmpty

      public static void ensureNotNullOrEmpty(@Nullable Collection<?> collection, @NotNull String message)
      Ensures that the provided collection is not null 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 is null or empty.
      Throws:
      LDAPSDKUsageException - If the provided collection is null or empty.
    • ensureNotNullOrEmpty

      public static void ensureNotNullOrEmpty(@Nullable Map<?,?> map)
      Ensures that the provided map is not null and contains at least one item.
      Parameters:
      map - The map to verify.
      Throws:
      LDAPSDKUsageException - If the provided map is null or empty.
    • ensureNotNullOrEmpty

      public static void ensureNotNullOrEmpty(@Nullable Map<?,?> map, @NotNull String message)
      Ensures that the provided map is not null 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 is null or empty.
      Throws:
      LDAPSDKUsageException - If the provided map is null or empty.
    • ensureNotNullOrEmpty

      public static void ensureNotNullOrEmpty(@Nullable Object[] array)
      Ensures that the provided array is not null and has a length of at least one.
      Parameters:
      array - The array to verify.
      Throws:
      LDAPSDKUsageException - If the provided array is null or empty.
    • ensureNotNullOrEmpty

      public static void ensureNotNullOrEmpty(@Nullable Object[] array, @NotNull String message)
      Ensures that the provided array is not null 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 is null or empty.
      Throws:
      LDAPSDKUsageException - If the provided array is null or empty.
    • ensureNotNullOrEmpty

      public static void ensureNotNullOrEmpty(@Nullable byte[] array)
      Ensures that the provided array is not null and has a length of at least one.
      Parameters:
      array - The array to verify.
      Throws:
      LDAPSDKUsageException - If the provided array is null or empty.
    • ensureNotNullOrEmpty

      public static void ensureNotNullOrEmpty(@Nullable byte[] array, @NotNull String message)
      Ensures that the provided array is not null 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 is null or empty.
      Throws:
      LDAPSDKUsageException - If the provided array is null or empty.
    • ensureNotNullOrEmpty

      public static void ensureNotNullOrEmpty(@Nullable char[] array)
      Ensures that the provided array is not null and has a length of at least one.
      Parameters:
      array - The array to verify.
      Throws:
      LDAPSDKUsageException - If the provided array is null or empty.
    • ensureNotNullOrEmpty

      public static void ensureNotNullOrEmpty(@Nullable char[] array, @NotNull String message)
      Ensures that the provided array is not null 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 is null or empty.
      Throws:
      LDAPSDKUsageException - If the provided array is null or empty.
    • ensureNotNullOrEmpty

      public static void ensureNotNullOrEmpty(@Nullable int[] array)
      Ensures that the provided array is not null and has a length of at least one.
      Parameters:
      array - The array to verify.
      Throws:
      LDAPSDKUsageException - If the provided array is null or empty.
    • ensureNotNullOrEmpty

      public static void ensureNotNullOrEmpty(@Nullable int[] array, @NotNull String message)
      Ensures that the provided array is not null 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 is null or empty.
      Throws:
      LDAPSDKUsageException - If the provided array is null or empty.
    • ensureNotNullOrEmpty

      public static void ensureNotNullOrEmpty(@Nullable long[] array)
      Ensures that the provided array is not null and has a length of at least one.
      Parameters:
      array - The array to verify.
      Throws:
      LDAPSDKUsageException - If the provided array is null or empty.
    • ensureNotNullOrEmpty

      public static void ensureNotNullOrEmpty(@Nullable long[] array, @NotNull String message)
      Ensures that the provided array is not null 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 is null or empty.
      Throws:
      LDAPSDKUsageException - If the provided array is null or empty.
    • ensureNotNullOrEmpty

      public static void ensureNotNullOrEmpty(@Nullable CharSequence charSequence)
      Ensures that the provided character sequence is not null and has a length of at least one.
      Parameters:
      charSequence - The character sequence to verify.
      Throws:
      LDAPSDKUsageException - If the provided character sequence is null or empty.
    • ensureNotNullOrEmpty

      public static void ensureNotNullOrEmpty(@Nullable CharSequence charSequence, @NotNull String message)
      Ensures that the provided character sequence is not null 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 is null or empty.
      Throws:
      LDAPSDKUsageException - If the provided character sequence is null or empty.
    • ensureTrue

      public static void ensureTrue(boolean condition) throws LDAPSDKUsageException
      Ensures that the provided condition is true.
      Parameters:
      condition - The condition to verify.
      Throws:
      LDAPSDKUsageException - If the provided condition is false.
    • ensureTrue

      public static void ensureTrue(boolean condition, @NotNull String message) throws LDAPSDKUsageException
      Ensures that the provided condition is true.
      Parameters:
      condition - The condition to verify.
      message - The message to include in the exception thrown if the provided object is null.
      Throws:
      LDAPSDKUsageException - If the provided condition is false.
    • ensureFalse

      public static void ensureFalse(boolean condition) throws LDAPSDKUsageException
      Ensures that the provided condition is false.
      Parameters:
      condition - The condition to verify.
      Throws:
      LDAPSDKUsageException - If the provided condition is true.
    • ensureFalse

      public static void ensureFalse(boolean condition, @NotNull String message) throws LDAPSDKUsageException
      Ensures that the provided condition is false.
      Parameters:
      condition - The condition to verify.
      message - The message to include in the exception thrown if the provided object is null.
      Throws:
      LDAPSDKUsageException - If the provided condition is true.
    • violation

      public static void violation(@NotNull String message) throws LDAPSDKUsageException
      Indicates that an expected condition was not true by throwing an LDAPSDKUsageException with the provided information.
      Parameters:
      message - The message to use for the resulting exception. It must not be null.
      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 an LDAPSDKUsageException with the provided information.
      Parameters:
      message - The message to use for the resulting exception. It must not be null.
      cause - The exception that triggered the violation. It may be null if there is no associated exception.
      Throws:
      LDAPSDKUsageException - To indicate that a violation occurred.