Class HasAtLeastSizeMatcher

  • All Implemented Interfaces:
    org.hamcrest.Matcher<Collection<?>>, org.hamcrest.SelfDescribing

    public class HasAtLeastSizeMatcher
    extends org.hamcrest.TypeSafeMatcher<Collection<?>>
    A custom matcher that checks if a collection has at least a specified minimum size.
    • Constructor Detail

      • HasAtLeastSizeMatcher

        public HasAtLeastSizeMatcher​(int minSize)
        Constructs a matcher that checks if a collection has at least the specified minimum size.
        Parameters:
        minSize - the minimum size the collection should have
    • Method Detail

      • matchesSafely

        protected boolean matchesSafely​(Collection<?> item)
        Checks if the collection has at least the specified minimum size.
        Specified by:
        matchesSafely in class org.hamcrest.TypeSafeMatcher<Collection<?>>
        Parameters:
        item - the collection to check
        Returns:
        true if the collection has at least the specified minimum size, false otherwise
      • describeTo

        public void describeTo​(org.hamcrest.Description description)
        Describes the matcher.
        Parameters:
        description - the description to be appended
      • hasAtLeastSize

        public static HasAtLeastSizeMatcher hasAtLeastSize​(int minSize)
        A static factory method to create an instance of the matcher.
        Parameters:
        minSize - the minimum size the collection should have
        Returns:
        an instance of HasAtLeastSizeMatcher