It is a matter of taste, but I would probably have used:
```
if (previous == null) {
    stepDefinitionsByPattern.put(stepDefinition.getPattern(), stepDefinition);
} else if (!haveSameLocation(previous, stepDefinition)) {
    throw new DuplicateStepDefinitionException(previous, stepDefinition);
}
```
In a method named addStepDefinition, the ```if (previous == null || haveSameLocation(previous, stepDefinition))``` triggered a "no, it is not right to add the stepDefinition in both these cases" in me, but it is actually ok, since put overwrites the previous step definition with the new one.