Type Parameters:
S - the type this validator
T - the type of the array
E - the type of elements in the array
All Known Subinterfaces:
ByteArrayValidator, ObjectArrayValidator<T,E>, PrimitiveBooleanArrayValidator, PrimitiveByteArrayValidator, PrimitiveCharacterArrayValidator, PrimitiveDoubleArrayValidator, PrimitiveFloatArrayValidator, PrimitiveIntegerArrayValidator, PrimitiveLongArrayValidator, PrimitiveShortArrayValidator

public interface ArrayComponent<S,T,E>
Methods that all array validators must contain.
  • Method Details

    • isEmpty

      S isEmpty()
      Ensures that the array is empty.
      Returns:
      this
      Throws:
      NullPointerException - if the value is null
      IllegalArgumentException - if the array is not empty
    • isNotEmpty

      S isNotEmpty()
      Ensures that the array is not empty.
      Returns:
      this
      Throws:
      NullPointerException - if the value is null
      IllegalArgumentException - if the array is empty
    • contains

      S contains(E expected)
      Ensures that the array contains an element.
      Parameters:
      expected - the element
      Returns:
      this
      Throws:
      NullPointerException - if the value or expected are null
      IllegalArgumentException - if the array does not contain expected
    • contains

      S contains(E expected, String name)
      Ensures that the array contains an element.
      Parameters:
      expected - the element
      name - the name of the element
      Returns:
      this
      Throws:
      NullPointerException - if the value or any of the arguments are null
      IllegalArgumentException - if:
      • name is empty
      • name contains whitespace
      • name is already in use by the value being validated or the validator context
      • the array does not contain expected
    • doesNotContain

      S doesNotContain(E unwanted)
      Ensures that the array does not contain unwanted.
      Parameters:
      unwanted - the unwanted element
      Returns:
      this
      Throws:
      NullPointerException - if the value or any of the arguments are null
      IllegalArgumentException - if the array contains unwanted
    • doesNotContain

      S doesNotContain(E unwanted, String name)
      Ensures that the array does not contain unwanted.
      Parameters:
      unwanted - the unwanted element
      name - the name of the element
      Returns:
      this
      Throws:
      NullPointerException - if the value or any of the arguments are null
      IllegalArgumentException - if:
      • name is empty
      • name contains whitespace
      • name is already in use by the value being validated or the validator context
      • the array contains unwanted
    • containsExactly

      S containsExactly(T expected)
      Ensures that the array consists of the same elements as expected, irrespective of their order.

      In contrast, isEqualTo() requires the same element ordering.

      Parameters:
      expected - the desired elements
      Returns:
      this
      Throws:
      NullPointerException - if the value or expected are null
      IllegalArgumentException - if:
      • the array is missing any element in expected
      • the array contains any element that is not in expected
    • containsExactly

      <C extends Collection<E>> S containsExactly(C expected)
      Ensures that the array consists of the same elements as expected, irrespective of their order.

      In contrast, isEqualTo() requires the same element ordering.

      Type Parameters:
      C - the type of collection to compare against
      Parameters:
      expected - the desired elements
      Returns:
      this
      Throws:
      NullPointerException - if the value or expected are null
      IllegalArgumentException - if:
      • the array is missing any element in expected
      • the array contains any element that is not in expected
    • containsExactly

      S containsExactly(T expected, String name)
      Ensures that the array consists of the same elements as expected, irrespective of their order.

      In contrast, isEqualTo() requires the same element ordering.

      Parameters:
      expected - the desired elements
      name - the name of the expected collection
      Returns:
      this
      Throws:
      NullPointerException - if the value or any of the arguments are null
      IllegalArgumentException - if:
      • name is empty
      • name contains whitespace
      • name is already in use by the value being validated or the validator context
      • the array and expected contain different elements, irrespective of their order
    • containsExactly

      <C extends Collection<E>> S containsExactly(C expected, String name)
      Ensures that the array consists of the same elements as expected, irrespective of their order.

      In contrast, isEqualTo() requires the same element ordering.

      Type Parameters:
      C - the type of collection to compare against
      Parameters:
      expected - the desired elements
      name - the name of the expected collection
      Returns:
      this
      Throws:
      NullPointerException - if the value or any of the arguments are null
      IllegalArgumentException - if:
      • name is empty
      • name contains whitespace
      • name is already in use by the value being validated or the validator context
      • the array and expected contain different elements, irrespective of their order
    • doesNotContainExactly

      S doesNotContainExactly(T unwanted)
      Ensures that the array and unwanted consist of different elements, irrespective of their order.
      Parameters:
      unwanted - the unwanted elements
      Returns:
      this
      Throws:
      NullPointerException - if the value or unwanted are null
      IllegalArgumentException - if the array consists of the same elements as unwanted, irrespective of their order
    • doesNotContainExactly

      <C extends Collection<E>> S doesNotContainExactly(C unwanted)
      Ensures that the array and unwanted consist of different elements, irrespective of their order.
      Type Parameters:
      C - the type of collection to compare against
      Parameters:
      unwanted - the unwanted elements
      Returns:
      this
      Throws:
      NullPointerException - if the value or unwanted are null
      IllegalArgumentException - if the array consists of the same elements as unwanted, irrespective of their order
    • doesNotContainExactly

      S doesNotContainExactly(T unwanted, String name)
      Ensures that the array and unwanted consist of different elements, irrespective of their order.
      Parameters:
      unwanted - the unwanted elements
      name - the name of the unwanted collection
      Returns:
      this
      Throws:
      NullPointerException - if the value or any of the arguments are null
      IllegalArgumentException - if:
      • name is empty
      • name contains whitespace
      • name is already in use by the value being validated or the validator context
      • the array consists of the same elements as unwanted, irrespective of their order
    • doesNotContainExactly

      <C extends Collection<E>> S doesNotContainExactly(C unwanted, String name)
      Ensures that the array and unwanted consist of different elements, irrespective of their order.
      Type Parameters:
      C - the type of collection to compare against
      Parameters:
      unwanted - the unwanted elements
      name - the name of the unwanted collection
      Returns:
      this
      Throws:
      NullPointerException - if the value or any of the arguments are null
      IllegalArgumentException - if:
      • name is empty
      • name contains whitespace
      • name is already in use by the value being validated or the validator context
      • the array consists of the same elements as unwanted, irrespective of their order
    • containsAny

      S containsAny(T expected)
      Ensures that the array contains any elements in expected.
      Parameters:
      expected - the desired elements
      Returns:
      this
      Throws:
      NullPointerException - if the value or expected are null
      IllegalArgumentException - if the array does not contain any element in expected
    • containsAny

      <C extends Collection<E>> S containsAny(C expected)
      Ensures that the array contains any elements in expected.
      Type Parameters:
      C - the type of collection to compare against
      Parameters:
      expected - the desired elements
      Returns:
      this
      Throws:
      NullPointerException - if the value or expected are null
      IllegalArgumentException - if the array does not contain any element in expected
    • containsAny

      S containsAny(T expected, String name)
      Ensures that the array contains at least one element in expected.
      Parameters:
      expected - the desired elements
      name - the name of the expected collection
      Returns:
      this
      Throws:
      NullPointerException - if the value or any of the arguments are null
      IllegalArgumentException - if:
      • name is empty
      • name contains whitespace
      • name is already in use by the value being validated or the validator context
      • the array does not contain any element in expected
    • containsAny

      <C extends Collection<E>> S containsAny(C expected, String name)
      Ensures that the array contains at least one element in expected.
      Type Parameters:
      C - the type of collection to compare against
      Parameters:
      expected - the desired elements
      name - the name of the expected collection
      Returns:
      this
      Throws:
      NullPointerException - if the value or any of the arguments are null
      IllegalArgumentException - if:
      • name is empty
      • name contains whitespace
      • name is already in use by the value being validated or the validator context
      • the array does not contain any element in expected/li>
    • doesNotContainAny

      S doesNotContainAny(T unwanted)
      Ensures that the array does not contain any of the elements in unwanted.
      Parameters:
      unwanted - the unwanted elements
      Returns:
      this
      Throws:
      NullPointerException - if the value or unwanted are null
      IllegalArgumentException - if the array contains any of the elements in unwanted
    • doesNotContainAny

      <C extends Collection<E>> S doesNotContainAny(C unwanted)
      Ensures that the array does not contain any of the elements in unwanted.
      Type Parameters:
      C - the type of collection to compare against
      Parameters:
      unwanted - the unwanted elements
      Returns:
      this
      Throws:
      NullPointerException - if the value or unwanted are null
      IllegalArgumentException - if the array contains any of the elements in unwanted
    • doesNotContainAny

      S doesNotContainAny(T unwanted, String name)
      Ensures that the array does not contain any of the elements in unwanted.
      Parameters:
      unwanted - the unwanted elements
      name - the name of the unwanted collection
      Returns:
      this
      Throws:
      NullPointerException - if the value or any of the arguments are null
      IllegalArgumentException - if:
      • name is empty
      • name contains whitespace
      • name is already in use by the value being validated or the validator context
      • the array contains any of the elements in unwanted
    • doesNotContainAny

      <C extends Collection<E>> S doesNotContainAny(C unwanted, String name)
      Ensures that the array does not contain any of the elements in unwanted.
      Type Parameters:
      C - the type of collection to compare against
      Parameters:
      unwanted - the unwanted elements
      name - the name of the unwanted collection
      Returns:
      this
      Throws:
      NullPointerException - if the value or any of the arguments are null
      IllegalArgumentException - if:
      • name is empty
      • name contains whitespace
      • name is already in use by the value being validated or the validator context
      • the array contains any of the elements in unwanted
    • containsAll

      S containsAll(T expected)
      Ensures that the array contains all the elements in expected.
      Parameters:
      expected - the desired elements
      Returns:
      this
      Throws:
      NullPointerException - if the value or expected are null
      IllegalArgumentException - if the array does not contain all the elements in expected
    • containsAll

      <C extends Collection<E>> S containsAll(C expected)
      Ensures that the array contains all the elements in expected.
      Type Parameters:
      C - the type of collection to compare against
      Parameters:
      expected - the desired elements
      Returns:
      this
      Throws:
      NullPointerException - if the value or expected are null
      IllegalArgumentException - if the array does not contain all the elements in expected
    • containsAll

      S containsAll(T expected, String name)
      Ensures that the array contains all the elements in expected.
      Parameters:
      expected - the desired elements
      name - the name of the expected collection
      Returns:
      this
      Throws:
      NullPointerException - if the value or any of the arguments are null
      IllegalArgumentException - if:
      • name is empty
      • name contains whitespace
      • name is already in use by the value being validated or the validator context
      • the array does not contain all the elements in expected/li>
    • containsAll

      <C extends Collection<E>> S containsAll(C expected, String name)
      Ensures that the array contains all the elements in expected.
      Type Parameters:
      C - the type of collection to compare against
      Parameters:
      expected - the desired elements
      name - the name of the expected collection
      Returns:
      this
      Throws:
      NullPointerException - if the value or any of the arguments are null
      IllegalArgumentException - if:
      • name is empty
      • name contains whitespace
      • name is already in use by the value being validated or the validator context
      • the array does not contain all elements in expected
    • doesNotContainAll

      S doesNotContainAll(T unwanted)
      Allows the array to contain some, but not all, elements from a collection.
      Parameters:
      unwanted - the unwanted elements
      Returns:
      this
      Throws:
      NullPointerException - if the value or unwanted are null
      IllegalArgumentException - if the array contains all the elements of unwanted
    • doesNotContainAll

      <C extends Collection<E>> S doesNotContainAll(C unwanted)
      Allows the array to contain some, but not all, elements from a collection.
      Type Parameters:
      C - the type of collection to compare against
      Parameters:
      unwanted - the unwanted elements
      Returns:
      this
      Throws:
      NullPointerException - if the value or unwanted are null
      IllegalArgumentException - if the array contains all the elements of unwanted
    • doesNotContainAll

      S doesNotContainAll(T unwanted, String name)
      Allows the array to contain some, but not all, elements from a collection.
      Parameters:
      unwanted - the unwanted elements
      name - the name of the unwanted collection
      Returns:
      this
      Throws:
      NullPointerException - if the value or any of the arguments are null
      IllegalArgumentException - if:
      • name is empty
      • name contains whitespace
      • name is already in use by the value being validated or the validator context
      • the array contains all the elements in unwanted
    • doesNotContainAll

      <C extends Collection<E>> S doesNotContainAll(C unwanted, String name)
      Allows the array to contain some, but not all, elements from a collection.
      Type Parameters:
      C - the type of collection to compare against
      Parameters:
      unwanted - the unwanted elements
      name - the name of the unwanted collection
      Returns:
      this
      Throws:
      NullPointerException - if the value or any of the arguments are null
      IllegalArgumentException - if:
      • name is empty
      • name contains whitespace
      • name is already in use by the value being validated or the validator context
      • the array contains all the elements in unwanted
    • isSorted

      S isSorted(Comparator<E> comparator)
      Ensures that the array is sorted.
      Parameters:
      comparator - the comparator that defines the expected order of the elements
      Returns:
      this
      Throws:
      NullPointerException - if the value or comparator are null
      IllegalArgumentException - if the array is not sorted
      See Also:
    • doesNotContainDuplicates

      S doesNotContainDuplicates()
      Ensures that the array does not contain any duplicate elements.
      Returns:
      this
      Throws:
      NullPointerException - if the value is null
      IllegalArgumentException - if the array contains any duplicate elements
    • length

      Returns a validator for the array's length.
      Returns:
      a validator for the array's length
      Throws:
      NullPointerException - if the value is null