com.xlrit.gears.runner.runnertarget.TaskExpression Maven / Gradle / Ivy
The newest version!
package com.xlrit.gears.runner.runnertarget;
import com.xlrit.gears.runner.scenario.ScenarioParser;
public record TaskExpression(TaskType type, String id) {
public static TaskExpression from(ScenarioParser.TaskExprContext ctx) {
if (ctx == null) return null;
TaskType type;
if (ctx.getText().startsWith("the only")) {
type = TaskType.Only;
} else if (ctx.getText().startsWith("the first")) {
type = TaskType.First;
} else {
type = TaskType.Identifier;
}
if (ctx.Identifier() == null) {
return new TaskExpression(type, null);
} else {
return new TaskExpression(type, ctx.Identifier().getSymbol().getText());
}
}
}