Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow feature value matchers to be optionally composed #12

Open
markhobson opened this issue Nov 8, 2017 · 0 comments
Open

Allow feature value matchers to be optionally composed #12

markhobson opened this issue Nov 8, 2017 · 0 comments

Comments

@markhobson
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant