## Pattern Variants

While aliases allow to explicitly define alternative patterns that match the same executable method, it can be cumbersome to list all the different alternatives when the variations between the patterns are small or localised in word alternatives. To this end, JBehave supports pattern variant directives. For example, let's consider the following step:

    When the item price is 10.0

If we also want to support the following equivalent expressions:

    When the item cost is 10.0
    When the price is 10.0
    When the cost is 10.0

then we could define two aliases, but it's simpler and more compact to write a pattern with variants. E.g.:

        @When("the {item |}{price|cost} is $price")
        public void theItemPriceIs(double price) {
            // ...
        }

In this example, we want the word "item" to be optional. Please note that we include a trailing space in the variant "{item |}" and not between this and the following variant ("{price|cost}") to prevent the resulting step from containing multiple consecutive spaces.

The pattern variants are built by the PatternVariantBuilder, which interprets the directives of the form:

        A {x|y|z} B => A x B, A y B, A z B