All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cucumber.api.Format 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 into an object such as a Date or a Calendar. For example, if you have the following Gherkin step with * a ISO 8601 date: *

*
 * Given the date is 2012-03-01T06:54:12
 * 
*

* Then the following Java Step Definition would convert that into a Date: *

*
 * @Given("^the date is (\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2})$")
 * public void the_date_is(@Format("yyyy-MM-dd'T'HH:mm:ss") Date date) {
 *     this.date = date;
 * }
 * 
*

* Or a Calendar: *

*
 * @Given("^the date is (\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2})$")
 * public void the_date_is(@Format("yyyy-MM-dd'T'HH:mm:ss") Calendar cal) {
 *     this.cal = cal;
 * }
 * 
*

* This annotation also works for data tables that are transformed to a list of beans with Date or Calendar fields. *

*/ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.PARAMETER) public @interface Format { String value(); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy