Class CollectionSizeMatcher<T extends Iterable<?>>

Type Parameters:
T - The type of the matched entity.
All Implemented Interfaces:
ElementMatcher<T>, ElementMatcher.Junction<T>

@Enhance public class CollectionSizeMatcher<T extends Iterable<?>> extends ElementMatcher.Junction.ForNonNullValues<T>
An element matcher that matches a collection by its size.
  • Field Details

    • size

      private final int size
      The expected size of the matched collection.
  • Constructor Details

    • CollectionSizeMatcher

      public CollectionSizeMatcher(int size)
      Creates a new matcher that matches the size of a matched collection.
      Parameters:
      size - The expected size of the matched collection.
  • Method Details

    • doMatch

      protected boolean doMatch(T target)
      Matches the supplied value if it was found not to be null.
      Specified by:
      doMatch in class ElementMatcher.Junction.ForNonNullValues<T extends Iterable<?>>
      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