@Test public void shouldPerformXorWhenTwoMatchers() throws Exception { when(matcher1.match(mail)).thenReturn(ImmutableList.of(ANY_AT_JAMES, ANY_AT_JAMES2)); when(matcher2.match(mail)).thenReturn(ImmutableList.of(ANY_AT_JAMES, OTHER_AT_JAMES)); testee.add(matcher1); testee.add(matcher2); assertThat(testee.match(mail)).containsOnly(ANY_AT_JAMES2, OTHER_AT_JAMES); }
@Override public Collection<MailAddress> match(Mail mail) { Set<MailAddress> recipients = getMatchers().stream() .map(Throwing.<Matcher, Set<MailAddress>>function(matcher -> applyMatcher(mail, matcher)).sneakyThrow()) .reduce(ImmutableSet.of(), this::performXor); if (recipients.isEmpty()) { return null; } return recipients; }
Xor extends GenericCompositeMatcher { @Override public Collection<MailAddress> match(Mail mail) { Set<MailAddress> recipients = getMatchers().stream() .map(Throwing.<Matcher, Set<MailAddress>>function(matcher -> applyMatcher(mail, matcher)).sneakyThrow()) .reduce(ImmutableSet.of(), this::performXor); if (recipients.isEmpty()) { return null; } return recipients; } }
Xor extends GenericCompositeMatcher { @Override public Collection<MailAddress> match(Mail mail) { Set<MailAddress> recipients = getMatchers().stream() .map(Throwing.<Matcher, Set<MailAddress>>function(matcher -> applyMatcher(mail, matcher)).sneakyThrow()) .reduce(ImmutableSet.of(), this::performXor); if (recipients.isEmpty()) { return null; } return recipients; }  }
Xor extends GenericCompositeMatcher { @Override public Collection<MailAddress> match(Mail mail) { Set<MailAddress> recipients = getMatchers().stream() .map(Throwing.<Matcher, Set<MailAddress>>function(matcher -> applyMatcher(mail, matcher)).sneakyThrow()) .reduce(ImmutableSet.of(), this::performXor); if (recipients.isEmpty()) { return null; } return recipients; }  @Override Collection<MailAddress> match(Mail mail); }
Xor extends GenericCompositeMatcher { @Override public Collection<MailAddress> match(Mail mail) { Set<MailAddress> recipients = getMatchers().stream() .map(Throwing.<Matcher, Set<MailAddress>>function(matcher -> applyMatcher(mail, matcher)).sneakyThrow()) .reduce(ImmutableSet.of(), this::performXor); if (recipients.isEmpty()) { return null; } return recipients; }  @Override Collection<MailAddress> match(Mail mail);  }