Skip to content

Commit

Permalink
java: require all GherkinDialect properties to be non-null (#329)
Browse files Browse the repository at this point in the history
While the code generation and package private constructor already
ensure that all fields are non-null, it is good to have this explicitly
enforced in the code.
  • Loading branch information
mpkorstanje authored Nov 28, 2024
1 parent 20ca981 commit caf524d
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions java/src/main/java/io/cucumber/gherkin/GherkinDialect.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;

import static java.util.Collections.unmodifiableList;
import static java.util.Objects.requireNonNull;

public final class GherkinDialect {
private final String language;
Expand All @@ -28,20 +30,20 @@ public final class GherkinDialect {
private final Map<String, List<StepKeywordType>> stepKeywordsTypes;

GherkinDialect(String language, String name, String nativeName, List<String> featureKeywords, List<String> ruleKeywords, List<String> scenarioKeywords, List<String> scenarioOutlineKeywords, List<String> backgroundKeywords, List<String> examplesKeywords, List<String> givenKeywords, List<String> whenKeywords, List<String> thenKeywords, List<String> andKeywords, List<String> butKeywords) {
this.language = language;
this.name = name;
this.nativeName = nativeName;
this.featureKeywords = featureKeywords;
this.ruleKeywords = ruleKeywords;
this.scenarioKeywords = scenarioKeywords;
this.scenarioOutlineKeywords = scenarioOutlineKeywords;
this.backgroundKeywords = backgroundKeywords;
this.examplesKeywords = examplesKeywords;
this.givenKeywords = givenKeywords;
this.whenKeywords = whenKeywords;
this.thenKeywords = thenKeywords;
this.andKeywords = andKeywords;
this.butKeywords = butKeywords;
this.language = requireNonNull(language);
this.name = requireNonNull(name);
this.nativeName = requireNonNull(nativeName);
this.featureKeywords = requireNonNull(featureKeywords);
this.ruleKeywords = requireNonNull(ruleKeywords);
this.scenarioKeywords = requireNonNull(scenarioKeywords);
this.scenarioOutlineKeywords = requireNonNull(scenarioOutlineKeywords);
this.backgroundKeywords = requireNonNull(backgroundKeywords);
this.examplesKeywords = requireNonNull(examplesKeywords);
this.givenKeywords = requireNonNull(givenKeywords);
this.whenKeywords = requireNonNull(whenKeywords);
this.thenKeywords = requireNonNull(thenKeywords);
this.andKeywords = requireNonNull(andKeywords);
this.butKeywords = requireNonNull(butKeywords);

List<String> stepKeywords = new ArrayList<>();
stepKeywords.addAll(givenKeywords);
Expand Down

0 comments on commit caf524d

Please sign in to comment.