Search in sources :

Example 1 with Format

use of cucumber.api.Format in project cucumber-jvm by cucumber.

the class ParameterInfo method fromMethod.

public static List<ParameterInfo> fromMethod(Method method) {
    List<ParameterInfo> result = new ArrayList<ParameterInfo>();
    Type[] genericParameterTypes = method.getGenericParameterTypes();
    Annotation[][] annotations = method.getParameterAnnotations();
    for (int i = 0; i < genericParameterTypes.length; i++) {
        String format = null;
        String delimiter = DEFAULT_DELIMITER;
        boolean transposed = false;
        Transformer<?> transformer = null;
        for (Annotation annotation : annotations[i]) {
            if (annotation instanceof Format) {
                format = ((Format) annotation).value();
            } else if (isAnnotatedWith(annotation, Format.class)) {
                format = getAnnotationForAnnotation(annotation, Format.class).value();
            }
            if (annotation instanceof Delimiter) {
                delimiter = ((Delimiter) annotation).value();
            } else if (isAnnotatedWith(annotation, Delimiter.class)) {
                delimiter = getAnnotationForAnnotation(annotation, Delimiter.class).value();
            }
            if (annotation instanceof Transpose) {
                transposed = ((Transpose) annotation).value();
            }
            if (annotation instanceof Transform) {
                transformer = getTransformer(annotation);
            } else if (isAnnotatedWith(annotation, Transform.class)) {
                transformer = getTransformer(getAnnotationForAnnotation(annotation, Transform.class));
            }
        }
        result.add(new ParameterInfo(genericParameterTypes[i], format, delimiter, transposed, transformer));
    }
    return result;
}
Also used : Delimiter(cucumber.api.Delimiter) ArrayList(java.util.ArrayList) Transpose(cucumber.api.Transpose) Annotation(java.lang.annotation.Annotation) ParameterizedType(java.lang.reflect.ParameterizedType) Type(java.lang.reflect.Type) Format(cucumber.api.Format) Transform(cucumber.api.Transform)

Aggregations

Delimiter (cucumber.api.Delimiter)1 Format (cucumber.api.Format)1 Transform (cucumber.api.Transform)1 Transpose (cucumber.api.Transpose)1 Annotation (java.lang.annotation.Annotation)1 ParameterizedType (java.lang.reflect.ParameterizedType)1 Type (java.lang.reflect.Type)1 ArrayList (java.util.ArrayList)1