cucumber.api.Delimiter Maven / Gradle / Ivy
package cucumber.api;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
*
* This annotation can be specified on step definition method parameters to give Cucumber a hint
* about how to transform a String to a list of objects. For example, if you have the following Gherkin step:
*
*
* Given the users adam, bob, john
*
*
* Then the following Java Step Definition would convert that into a List:
*
*
* @Given("^the users ([a-z](?:, [a-z]+))$")
* public void the_users(@Delimiter(", ") List<String> users) {
* this.users = users;
* }
*
*
* This annotation also works with regular expression patterns. Step definition method parameters of type
* {@link java.util.List} without the {@link Delimiter} annotation will default to the pattern {@code ",\\s?"}.
*
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.PARAMETER, ElementType.ANNOTATION_TYPE})
public @interface Delimiter {
String value();
}