io.cucumber.cucumberexpressions.Argument Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cucumber-expressions Show documentation
Show all versions of cucumber-expressions Show documentation
Cucumber Expressions are simple patterns for matching Step Definitions with Gherkin steps
package io.cucumber.cucumberexpressions;
import org.apiguardian.api.API;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
@API(status = API.Status.STABLE)
public final class Argument {
private final ParameterType parameterType;
private final Group group;
static List> build(Group group, List> parameterTypes) {
List argGroups = group.getChildren();
if (argGroups.size() != parameterTypes.size()) {
// This requires regex injection through a Cucumber expression.
// Regex injection should be be possible any more.
throw new IllegalArgumentException(String.format("Group has %s capture groups, but there were %s parameter types", argGroups.size(), parameterTypes.size()));
}
List> args = new ArrayList<>(argGroups.size());
for (int i = 0; i < parameterTypes.size(); i++) {
Group argGroup = argGroups.get(i);
ParameterType> parameterType = parameterTypes.get(i);
args.add(new Argument<>(argGroup, parameterType));
}
return args;
}
private Argument(Group group, ParameterType parameterType) {
this.group = group;
this.parameterType = parameterType;
}
public Group getGroup() {
return group;
}
public T getValue() {
return parameterType.transform(group.getValues());
}
public Type getType() {
return parameterType.getType();
}
public ParameterType getParameterType() {
return parameterType;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy