Interface CollectionComponent<S,E>
- Type Parameters:
S- the type of this validatorE- the type of elements in the collection
- All Known Subinterfaces:
CollectionValidator<T,,E> ListValidator<T,E>
Collection validators must contain.-
Method Summary
Modifier and TypeMethodDescriptionEnsures that the collection contains an element.Ensures that the collection contains an element.containsAll(E[] expected) Ensures that the collection contains all the elements inexpected.containsAll(E[] expected, String name) Ensures that the collection contains all the elements inexpected.containsAll(Collection<E> expected) Ensures that the collection contains all the elements inexpected.containsAll(Collection<E> expected, String name) Ensures that the collection contains all the elements inexpected.containsAny(E[] expected) Ensures that the collection contains any elements inexpected.containsAny(E[] expected, String name) Ensures that the collection contains at least one element inexpected.containsAny(Collection<E> expected) Ensures that the collection contains any elements inexpected.containsAny(Collection<E> expected, String name) Ensures that the collection contains at least one element inexpected.containsExactly(E[] expected) Ensures that the collection consists of the same elements asexpected, irrespective of their order.containsExactly(E[] expected, String name) Ensures that the collection consists of the same elements asexpected, irrespective of their order.containsExactly(Collection<E> expected) Ensures that the collection consists of the same elements asexpected, irrespective of their order.containsExactly(Collection<E> expected, String name) Ensures that the collection consists of the same elements asexpected, irrespective of their order.doesNotContain(E unwanted) Ensures that the collection does not containunwanted.doesNotContain(E unwanted, String name) Ensures that the collection does not containunwanted.doesNotContainAll(E[] unwanted) Allows the collection to contain some, but not all, elements from a collection.doesNotContainAll(E[] unwanted, String name) Allows the collection to contain some, but not all, elements from a collection.doesNotContainAll(Collection<E> unwanted) Allows the collection to contain some, but not all, elements from another collection.doesNotContainAll(Collection<E> unwanted, String name) Allows the collection to contain some, but not all, elements from another collection.doesNotContainAny(E[] unwanted) Ensures that the collection does not contain any of the elements inunwanted.doesNotContainAny(E[] unwanted, String name) Ensures that the collection does not contain any of the elements inunwanted.doesNotContainAny(Collection<E> unwanted) Ensures that the collection does not contain any of the elements inunwanted.doesNotContainAny(Collection<E> unwanted, String name) Ensures that the collection does not contain any of the elements inunwanted.Ensures that the collection does not contain any duplicate elements.doesNotContainExactly(E[] unwanted) Ensures that the collection andunwantedconsist of different elements, irrespective of their order.doesNotContainExactly(E[] unwanted, String name) Ensures that the collection andunwantedconsist of different elements, irrespective of their order.doesNotContainExactly(Collection<E> unwanted) Ensures that the collection andunwantedconsist of different elements, irrespective of their order.doesNotContainExactly(Collection<E> unwanted, String name) Ensures that the collection andunwantedconsist of different elements, irrespective of their order.isEmpty()Ensures that the collection is empty.Ensures that the collection is not empty.size()Returns a validator for the collection's size.
-
Method Details
-
isEmpty
S isEmpty()Ensures that the collection is empty.- Returns:
- this
- Throws:
NullPointerException- if the value isnullIllegalArgumentException- if the collection is not empty
-
isNotEmpty
S isNotEmpty()Ensures that the collection is not empty.- Returns:
- this
- Throws:
NullPointerException- if the value isnullIllegalArgumentException- if the collection is empty
-
contains
Ensures that the collection contains an element.- Parameters:
expected- the element- Returns:
- this
- Throws:
NullPointerException- if the value orexpectedare nullIllegalArgumentException- if the collection does not containexpected
-
doesNotContain
Ensures that the collection does not containunwanted.- Parameters:
unwanted- the unwanted element- Returns:
- this
- Throws:
NullPointerException- if the value orunwantedare nullIllegalArgumentException- if the collection containsunwanted
-
contains
Ensures that the collection contains an element.- Parameters:
expected- the elementname- the name of the element- Returns:
- this
- Throws:
NullPointerException- if the value or any of the arguments are nullIllegalArgumentException- if:nameis emptynamecontains whitespacenameis already in use by the value being validated or the validator context- the collection does not contain
expected
-
doesNotContain
Ensures that the collection does not containunwanted.- Parameters:
unwanted- the unwanted elementname- the name of the element- Returns:
- this
- Throws:
NullPointerException- if the value or any of the arguments are nullIllegalArgumentException- if:nameis emptynamecontains whitespacenameis already in use by the value being validated or the validator context- the collection contains
unwanted
-
containsExactly
Ensures that the collection consists of the same elements asexpected, irrespective of their order.In contrast,
isEqualTo()requires the same element ordering.This method is provided for convenience, without any implied performance benefits compared to
containsExactly(Collection)- Parameters:
expected- the desired elements- Returns:
- this
- Throws:
NullPointerException- if the value orexpectedare nullIllegalArgumentException- if:- the collection is missing any element in
expected - the collection contains any element that is not in
expected
- the collection is missing any element in
-
doesNotContainExactly
Ensures that the collection andunwantedconsist of different elements, irrespective of their order.This method is provided for convenience, without any implied performance benefits compared to
doesNotContainExactly(Collection)- Parameters:
unwanted- the unwanted elements- Returns:
- this
- Throws:
NullPointerException- if the value orunwantedare nullIllegalArgumentException- if the collection consists of the same elements asunwanted, irrespective of their order
-
containsExactly
Ensures that the collection consists of the same elements asexpected, irrespective of their order.In contrast,
isEqualTo()requires the same element ordering.- Parameters:
expected- the desired elements- Returns:
- this
- Throws:
NullPointerException- if the value orexpectedare nullIllegalArgumentException- if:- the collection is missing any element in
expected - the collection contains any element that is not in
expected
- the collection is missing any element in
-
doesNotContainExactly
Ensures that the collection andunwantedconsist of different elements, irrespective of their order.- Parameters:
unwanted- the unwanted elements- Returns:
- this
- Throws:
NullPointerException- if the value orunwantedare nullIllegalArgumentException- if the collection consists of the same elements asunwanted, irrespective of their order
-
containsExactly
Ensures that the collection consists of the same elements asexpected, irrespective of their order.In contrast,
isEqualTo()requires the same element ordering.This method is provided for convenience, without any implied performance benefits compared to
containsExactly(Collection, String)- Parameters:
expected- the desired elementsname- the name of the expected collection- Returns:
- this
- Throws:
NullPointerException- if the value or any of the arguments are nullIllegalArgumentException- if:nameis emptynamecontains whitespacenameis already in use by the value being validated or the validator context- the collection and
expectedcontain different elements, irrespective of their order
-
doesNotContainExactly
Ensures that the collection andunwantedconsist of different elements, irrespective of their order.This method is provided for convenience, without any implied performance benefits compared to
doesNotContainExactly(Collection, String)- Parameters:
unwanted- the unwanted elementsname- the name of the unwanted collection- Returns:
- this
- Throws:
NullPointerException- if the value or any of the arguments are nullIllegalArgumentException- if:nameis emptynamecontains whitespacenameis already in use by the value being validated or the validator context- the collection consists of the same elements as
unwanted, irrespective of their order
-
containsExactly
Ensures that the collection consists of the same elements asexpected, irrespective of their order.In contrast,
isEqualTo()requires the same element ordering.- Parameters:
expected- the desired elementsname- the name of the expected collection- Returns:
- this
- Throws:
NullPointerException- if the value or any of the arguments are nullIllegalArgumentException- if:nameis emptynamecontains whitespacenameis already in use by the value being validated or the validator context- the collection and
expectedcontain different elements, irrespective of their order
-
doesNotContainExactly
Ensures that the collection andunwantedconsist of different elements, irrespective of their order.- Parameters:
unwanted- the unwanted elementsname- the name of the unwanted collection- Returns:
- this
- Throws:
NullPointerException- if the value or any of the arguments are nullIllegalArgumentException- if:nameis emptynamecontains whitespacenameis already in use by the value being validated or the validator context- the collection consists of the same elements as
unwanted, irrespective of their order
-
containsAny
Ensures that the collection contains any elements inexpected.This method is provided for convenience, without any implied performance benefits compared to
containsAny(Collection)- Parameters:
expected- the desired elements- Returns:
- this
- Throws:
NullPointerException- if the value orexpectedare nullIllegalArgumentException- if the collection does not contain any element inexpected
-
doesNotContainAny
Ensures that the collection does not contain any of the elements inunwanted.This method is provided for convenience, without any implied performance benefits compared to
doesNotContainAny(Collection)- Parameters:
unwanted- the unwanted elements- Returns:
- this
- Throws:
NullPointerException- if the value orunwantedare nullIllegalArgumentException- if the collection contains any of the elements inunwanted
-
containsAny
Ensures that the collection contains any elements inexpected.- Parameters:
expected- the desired elements- Returns:
- this
- Throws:
NullPointerException- if the value orexpectedare nullIllegalArgumentException- if the collection does not contain any element inexpected
-
doesNotContainAny
Ensures that the collection does not contain any of the elements inunwanted.- Parameters:
unwanted- the unwanted elements- Returns:
- this
- Throws:
NullPointerException- if the value orunwantedare nullIllegalArgumentException- if the collection contains any of the elements inunwanted
-
containsAny
Ensures that the collection contains at least one element inexpected.This method is provided for convenience, without any implied performance benefits compared to
containsAny(Collection, String)- Parameters:
expected- the desired elementsname- the name of the expected collection- Returns:
- this
- Throws:
NullPointerException- if the value or any of the arguments are nullIllegalArgumentException- if:nameis emptynamecontains whitespacenameis already in use by the value being validated or the validator context- the collection does not contain any element in
expected
-
doesNotContainAny
Ensures that the collection does not contain any of the elements inunwanted.This method is provided for convenience, without any implied performance benefits compared to
doesNotContainAny(Collection, String)- Parameters:
unwanted- the unwanted elementsname- the name of the unwanted collection- Returns:
- this
- Throws:
NullPointerException- if the value or any of the arguments are nullIllegalArgumentException- if:nameis emptynamecontains whitespacenameis already in use by the value being validated or the validator context- the collection contains any of the elements in
unwanted
-
containsAny
Ensures that the collection contains at least one element inexpected.- Parameters:
expected- the desired elementsname- the name of the expected collection- Returns:
- this
- Throws:
NullPointerException- if the value or any of the arguments are nullIllegalArgumentException- if:nameis emptynamecontains whitespacenameis already in use by the value being validated or the validator context- the collection does not contain any element in
expected
-
doesNotContainAny
Ensures that the collection does not contain any of the elements inunwanted.- Parameters:
unwanted- the unwanted elementsname- the name of the unwanted collection- Returns:
- this
- Throws:
NullPointerException- if the value or any of the arguments are nullIllegalArgumentException- if:nameis emptynamecontains whitespacenameis already in use by the value being validated or the validator context- the collection contains any of the elements in
unwanted
-
containsAll
Ensures that the collection contains all the elements inexpected.This method is provided for convenience, without any implied performance benefits compared to
containsAll(Collection)- Parameters:
expected- the desired elements- Returns:
- this
- Throws:
NullPointerException- if the value orexpectedare nullIllegalArgumentException- if the collection does not contain all the elements inexpected
-
doesNotContainAll
Allows the collection to contain some, but not all, elements from a collection.This method is provided for convenience, without any implied performance benefits compared to
doesNotContainAll(Collection)- Parameters:
unwanted- the unwanted elements- Returns:
- this
- Throws:
NullPointerException- if the value orunwantedare nullIllegalArgumentException- if the collection contains all the elements inunwanted
-
containsAll
Ensures that the collection contains all the elements inexpected.- Parameters:
expected- the desired elements- Returns:
- this
- Throws:
NullPointerException- if the value orexpectedare nullIllegalArgumentException- if the collection does not contain all the elements inexpected
-
doesNotContainAll
Allows the collection to contain some, but not all, elements from another collection.- Parameters:
unwanted- the unwanted elements- Returns:
- this
- Throws:
NullPointerException- if the value orunwantedare nullIllegalArgumentException- if the collection contains all the elements inunwanted
-
containsAll
Ensures that the collection contains all the elements inexpected.This method is provided for convenience, without any implied performance benefits compared to
containsAll(Collection, String)- Parameters:
expected- the desired elementsname- the name of the expected collection- Returns:
- this
- Throws:
NullPointerException- if the value or any of the arguments are nullIllegalArgumentException- if:nameis emptynamecontains whitespacenameis already in use by the value being validated or the validator context- the collection does not contain all elements in
expected
-
doesNotContainAll
Allows the collection to contain some, but not all, elements from a collection.- Parameters:
unwanted- the unwanted elementsname- the name of the unwanted collection- Returns:
- this
- Throws:
NullPointerException- if the value or any of the arguments are nullIllegalArgumentException- if:nameis emptynamecontains whitespacenameis already in use by the value being validated or the validator context- the collection contains all the elements in
unwanted
-
containsAll
Ensures that the collection contains all the elements inexpected.- Parameters:
expected- the desired elementsname- the name of the expected collection- Returns:
- this
- Throws:
NullPointerException- if the value or any of the arguments are nullIllegalArgumentException- if:nameis emptynamecontains whitespacenameis already in use by the value being validated or the validator context- the collection does not contain all elements in
expected
-
doesNotContainAll
Allows the collection to contain some, but not all, elements from another collection.- Parameters:
unwanted- the unwanted elementsname- the name of the unwanted collection- Returns:
- this
- Throws:
NullPointerException- if the value or any of the arguments are nullIllegalArgumentException- if:nameis emptynamecontains whitespacenameis already in use by the value being validated or the validator context- the collection contains all the elements in
unwanted
-
doesNotContainDuplicates
S doesNotContainDuplicates()Ensures that the collection does not contain any duplicate elements.- Returns:
- this
- Throws:
NullPointerException- if the value isnullIllegalArgumentException- if the collection contains any duplicate elements
-
size
Returns a validator for the collection's size.- Returns:
- a validator for the collection's size
- Throws:
NullPointerException- if the value isnull
-