org.sonar.gherkin.parser.GherkinDialect Maven / Gradle / Ivy
The newest version!
/*
* SonarQube Cucumber Gherkin Analyzer
* Copyright (C) 2016-2017 David RACODON
* [email protected]
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package org.sonar.gherkin.parser;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
public class GherkinDialect {
private final Map> keywords;
private String language;
public GherkinDialect(String language, Map> keywords) {
this.language = language;
this.keywords = keywords;
}
public Set getFeatureKeywords() {
return keywords.get("feature").stream().collect(Collectors.toSet());
}
public Set getScenarioKeywords() {
return keywords.get("scenario").stream().collect(Collectors.toSet());
}
public Set getStepKeywords() {
Set result = new HashSet<>();
result.addAll(keywords.get("given"));
result.addAll(keywords.get("when"));
result.addAll(keywords.get("then"));
result.addAll(keywords.get("and"));
result.addAll(keywords.get("but"));
return result;
}
public Set getGivenStepKeywords() {
return keywords.get("given").stream().filter(k -> !"* ".equals(k)).collect(Collectors.toSet());
}
public Set getWhenStepKeywords() {
return keywords.get("when").stream().filter(k -> !"* ".equals(k)).collect(Collectors.toSet());
}
public Set getThenStepKeywords() {
return keywords.get("then").stream().filter(k -> !"* ".equals(k)).collect(Collectors.toSet());
}
public Set getAndStepKeywords() {
return keywords.get("and").stream().filter(k -> !"* ".equals(k)).collect(Collectors.toSet());
}
public Set getButStepKeywords() {
return keywords.get("but").stream().filter(k -> !"* ".equals(k)).collect(Collectors.toSet());
}
public Set getBackgroundKeywords() {
return keywords.get("background").stream().collect(Collectors.toSet());
}
public Set getScenarioOutlineKeywords() {
return keywords.get("scenarioOutline").stream().collect(Collectors.toSet());
}
public Set getExamplesKeywords() {
return keywords.get("examples").stream().collect(Collectors.toSet());
}
public String getLanguage() {
return language;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy