Skip to content

Allow feature value matchers to be optionally composed #12

Description

@markhobson

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions