unruly / java-8-matchers

Hamcrest Matchers for Java 8 features
MIT License
23 stars 5 forks source link

Java8Matcher where matcher argument returns a Matcher #16

Open arian opened 5 years ago

arian commented 5 years ago

Basic idea, add a method with the signature:

public static <I, O> Matcher<I> where(DescribableFunction<? super I, O> property, Function<I, Matcher<? super O>> matcher);

So you could write:

assertThat(someList, where(String::toUpperCase, str -> equalTo(str)));

my actual use case is a bit more complex than this.