Skip to content

Commit

Permalink
refactor: Allow translator factories to return null to indicate tha…
Browse files Browse the repository at this point in the history
…t no translator has been created.

Signed-off-by: Michael Simons <[email protected]>
  • Loading branch information
michael-simons committed Jan 14, 2025
1 parent 6d1c460 commit 0a691b2
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions neo4j-jdbc/src/main/java/org/neo4j/jdbc/Neo4jDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -693,9 +693,14 @@ static SQLException noTranslatorsAvailableException() {

private static List<Translator> sortedListOfTranslators(Map<String, ?> config, List<TranslatorFactory> factories) {
if (factories.size() == 1) {
return List.of(factories.get(0).create(config));
var t1 = factories.get(0).create(config);
return (t1 != null) ? List.of(t1) : List.of();
}
return factories.stream().map(factory -> factory.create(config)).sorted(TranslatorComparator.INSTANCE).toList();
return factories.stream()
.map(factory -> factory.create(config))
.filter(Objects::nonNull)
.sorted(TranslatorComparator.INSTANCE)
.toList();
}

@Override
Expand Down

0 comments on commit 0a691b2

Please sign in to comment.