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

cucumber.runtime.JdkPatternArgumentMatcher Maven / Gradle / Ivy

There is a newer version: 1.2.6
Show newest version
package cucumber.runtime;

import gherkin.formatter.Argument;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class JdkPatternArgumentMatcher {
    private final Pattern pattern;

    public JdkPatternArgumentMatcher(Pattern pattern) {
        this.pattern = pattern;
    }

    public List argumentsFrom(String stepName) {
        Matcher matcher = pattern.matcher(stepName);
        if (matcher.matches()) {
            List arguments = new ArrayList();
            for (int i = 1; i <= matcher.groupCount(); i++) {
                arguments.add(new Argument(matcher.start(i), matcher.group(i)));
            }
            return arguments;
        } else {
            return null;
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy