Class CollectionElementMatcher<T>

Type Parameters:
T - The type of the elements contained by the collection.
All Implemented Interfaces:
ElementMatcher<Iterable<? extends T>>, ElementMatcher.Junction<Iterable<? extends T>>

@Enhance public class CollectionElementMatcher<T> extends ElementMatcher.Junction.ForNonNullValues<Iterable<? extends T>>
A matcher that matches a given element of a collection. If no such element is contained by the matched iterable, the matcher returns false.
  • Field Details

    • index

      private final int index
      The index of the matched element.
    • matcher

      private final ElementMatcher<? super T> matcher
      The matcher for the given element, if it exists.
  • Constructor Details

    • CollectionElementMatcher

      public CollectionElementMatcher(int index, ElementMatcher<? super T> matcher)
      Creates a new matcher for an element in a collection.
      Parameters:
      index - The index of the matched element.
      matcher - The matcher for the given element, if it exists.
  • Method Details

    • doMatch

      protected boolean doMatch(Iterable<? extends T> target)
      Matches the supplied value if it was found not to be null.
      Specified by:
      doMatch in class ElementMatcher.Junction.ForNonNullValues<Iterable<? extends T>>
      Parameters:
      target - The instance to be matched.
      Returns:
      true if the given element is matched by this matcher or false otherwise.
    • toString

      public String toString()
      Overrides:
      toString in class Object