title: How can I create a custom ArgumentMatcher that accepts arguments from other matchers?
body: <p>I'm currently writing unit tests on a code base that uses a lot of <code>ActionEvent</code>'s internally, and since <code>ActionEvent</code> doesn't override <code>equals()</code>, I'm creating a custom <code>ArgumentMatcher</code> to match <code>ActionEvent</code>'s.</p>
  
  <p>My <code>ArgumentMatcher</code> currently looks like this:</p>
  
  <pre><code>public class ActionEventMatcher extends ArgumentMatcher&lt;ActionEvent&gt; {
      private Object source;
      private int id;
      private String actionCommand;
  
      public ActionEventMatcher(Object source, int id, String actionCommand) {
          this.source = source;
          this.id = id;
          this.actionCommand = actionCommand;
      }
  
      @Override
      public boolean matches(Object argument) {
          if (!(argument instanceof ActionEvent))
              return false;
          ActionEvent e = (ActionEvent)argument;
  
          return source.equals(e.getSource()) &amp;&amp;
              id == e.getId() &amp;&amp; actionCommand.equals(e.getActionCommand());
      }
  }
  </code></pre>
  
  <p>I would like to know if it possible to change my <code>ArgumentMatcher</code> so that it accepts arguments that were created from other matchers.  For instance, if I have a method called <code>actionEvent()</code> that returns the matcher, I would like to be able to do the following:</p>
  
  <pre><code>verify(mock).fireEvent(argThat(actionEvent(same(source), anyInt(), eq("actionCommand"))));
  </code></pre>
  
  <p>Is there a way to have a custom <code>ArgumentMatcher</code> that accepts arguments from other matchers this way?</p>