Skip to content

Commit

Permalink
fix: improved performance to get the default dialect for #361
Browse files Browse the repository at this point in the history
  • Loading branch information
U117293 authored and U117293 committed Feb 27, 2025
1 parent 999af84 commit 6e0de0d
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@

public final class GherkinDialectProvider {

private final String defaultDialectName;
private final GherkinDialect defaultDialect;

public GherkinDialectProvider(String defaultDialectName) {
this.defaultDialectName = requireNonNull(defaultDialectName);
this.defaultDialect = getDialect(defaultDialectName)
.orElseThrow(() -> new ParserException.NoSuchLanguageException(defaultDialectName, null));
}

public GherkinDialectProvider() {
this("en");
}

public GherkinDialect getDefaultDialect() {
return getDialect(defaultDialectName).orElseThrow(() -> new ParserException.NoSuchLanguageException(defaultDialectName, null));
return defaultDialect;
}

public Optional<GherkinDialect> getDialect(String language) {
Expand Down

0 comments on commit 6e0de0d

Please sign in to comment.