A common use-case is to compose feature matchers only when their values are specified. The current API makes this hard.
Consider a simple example:
compose("a person with", hasFeatureValue("title", Person::getTitle, expected.getTitle()))
.and(hasFeatureValue("first name", Person::getFirstName, expected.getFirstName()))
.and(hasFeatureValue("last name", Person::getLastName, expected.getLastName()));
If any of the expected values are null then a matcher is still created and added to the composed matcher. Perhaps, if the value was an Optional then hasFeatureValue could return an Optional<Matcher> which and could then only append if not empty.
A common use-case is to compose feature matchers only when their values are specified. The current API makes this hard.
Consider a simple example:
If any of the expected values are
nullthen a matcher is still created and added to the composed matcher. Perhaps, if the value was anOptionalthenhasFeatureValuecould return anOptional<Matcher>whichandcould then only append if not empty.