io.cucumber.java.AbstractJavaSnippet Maven / Gradle / Ivy
package io.cucumber.java;
import io.cucumber.core.backend.Snippet;
import io.cucumber.datatable.DataTable;
import java.lang.reflect.Type;
import java.util.Map;
import static java.util.stream.Collectors.joining;
abstract class AbstractJavaSnippet implements Snippet {
@Override
public final String arguments(Map arguments) {
return arguments.entrySet()
.stream()
.map(argType -> getArgType(argType.getValue()) + " " + argType.getKey())
.collect(joining(", "));
}
private String getArgType(Type argType) {
if (argType instanceof Class) {
Class cType = (Class) argType;
if (cType.equals(DataTable.class)) {
return cType.getName();
}
return cType.getSimpleName();
}
// Got a better idea? Send a PR.
return argType.toString();
}
@Override
public final String tableHint() {
return "" +
" // For automatic transformation, change DataTable to one of\n" +
" // E, List, List>, List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy