Class ListMatcher<T>

java.lang.Object
org.hamcrest.BaseMatcher<List<T>>
org.axonframework.test.matchers.ListMatcher<T>
All Implemented Interfaces:
org.hamcrest.Matcher<List<T>>, org.hamcrest.SelfDescribing
Direct Known Subclasses:
ExactSequenceMatcher, ListWithAllOfMatcher, ListWithAnyOfMatcher, SequenceMatcher

public abstract class ListMatcher<T> extends org.hamcrest.BaseMatcher<List<T>>
Abstract implementation for matchers that use event-specific matchers to match against a list of items.
Since:
1.1
Author:
Allard Buijze
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    ListMatcher(org.hamcrest.Matcher<? super T>... matchers)
    Creates an abstract matcher to match a number of Matchers against Events contained inside a Collection.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract void
    describeCollectionType(org.hamcrest.Description description)
    Describes the type of collection expected.
    void
    describeTo(org.hamcrest.Description description)
     
    protected String
    The message to append behind a failing matcher.
    protected String
    The separator to use between the two last events.
    protected List<org.hamcrest.Matcher<? super T>>
    Returns a read-only list of Matchers, in the order they were provided in the constructor.
    boolean
     
    protected abstract boolean
    Evaluates the matcher for argument item.
    protected boolean
    matchRemainder(Iterator<org.hamcrest.Matcher<? super T>> matcherIterator)
    Matches all the remaining Matchers in the given matcherIterator against null.
    protected void
    reportFailed(org.hamcrest.Matcher<? super T> matcher)
    Report the given matcher as a failing matcher.

    Methods inherited from class org.hamcrest.BaseMatcher

    _dont_implement_Matcher___instead_extend_BaseMatcher_, describeMismatch, isNotNull, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • ListMatcher

      @SafeVarargs protected ListMatcher(org.hamcrest.Matcher<? super T>... matchers)
      Creates an abstract matcher to match a number of Matchers against Events contained inside a Collection.
      Parameters:
      matchers - The matchers to match the individual Events in the Collection
  • Method Details

    • matches

      public boolean matches(Object item)
    • matchesList

      protected abstract boolean matchesList(List<T> item)
      Evaluates the matcher for argument item. The item has been verified to be a list, but the exact type of contents of a list cannot be verified, due to Erasure of Generic Types.
      Parameters:
      item - the object against which the matcher is evaluated.
      Returns:
      true if item matches, otherwise false.
      See Also:
      • BaseMatcher
    • matchRemainder

      protected boolean matchRemainder(Iterator<org.hamcrest.Matcher<? super T>> matcherIterator)
      Matches all the remaining Matchers in the given matcherIterator against null.
      Parameters:
      matcherIterator - The iterator potentially containing more matchers
      Returns:
      true if no matchers remain or all matchers succeeded
    • reportFailed

      protected void reportFailed(org.hamcrest.Matcher<? super T> matcher)
      Report the given matcher as a failing matcher. This will be used in the error reporting.
      Parameters:
      matcher - The failing matcher.
    • getMatchers

      protected List<org.hamcrest.Matcher<? super T>> getMatchers()
      Returns a read-only list of Matchers, in the order they were provided in the constructor.
      Returns:
      a read-only list of Matchers, in the order they were provided in the constructor
    • describeCollectionType

      protected abstract void describeCollectionType(org.hamcrest.Description description)
      Describes the type of collection expected. To be used in the sentence: "list with ... of: ". E.g. "all" or "sequence".
      Parameters:
      description - the description to append the collection type to
    • describeTo

      public void describeTo(org.hamcrest.Description description)
    • failedMatcherMessage

      protected String failedMatcherMessage()
      The message to append behind a failing matcher. Defaults to FAILED!.
      Returns:
      The message to append behind a failing matcher
    • getLastSeparator

      protected String getLastSeparator()
      The separator to use between the two last events. Defaults to "and".
      Returns:
      The separator to use between the two last events. Defaults to "and".