Java 8 Streams - Filter More Than One Condition

Simple enough

resultList.stream()
        .filter(fixture -> fixture.getHome().equals(team) || fixture.getAway().equals(team)))
        .collect(toList());

EDIT: This is on the assumption that order does not matter to you. If your final list needs to have home result and then away, have a look at Elliott Frisch's answer.


If you wan to get fancy with lambdas:

Predicate<FixtureResult> isHome = fr -> fr.getHome().equals(team)
Predicate<FixtureResult> isAway = fr -> fr.getAway().equals(team)

resultList.stream()
  .filter(isHome.or(isAway))
  .collect(toList()));

You could even extract the compose predicate to test it in isolation, with no streams involved, which is good for more complex predicates:

Predicate<FixtureResult> isHomeOrAway = isHome.or(isAway)

assertTrue(isHomeOrAway(homeFixture)); 
...