Skip to content

Commit

Permalink
Merge pull request #105 from folded-ear/unitless-batch-load
Browse files Browse the repository at this point in the history
can't use Map.of() for empty unit lookups, due to null key restriction
  • Loading branch information
barneyb authored Sep 29, 2024
2 parents ef299b5 + 1e07632 commit 5907952
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import java.util.function.Function;
import java.util.stream.Collectors;

import static java.util.Collections.emptyMap;

@Component
public class UnitOfMeasureBatchLoader implements BatchLoader<Long, UnitOfMeasure> {

Expand All @@ -29,7 +31,7 @@ public CompletionStage<List<UnitOfMeasure>> load(List<Long> uomIds) {
.filter(Objects::nonNull)
.collect(Collectors.toSet());
Map<Long, UnitOfMeasure> byId;
if (nonNullIds.isEmpty()) byId = Map.of();
if (nonNullIds.isEmpty()) byId = emptyMap();
else byId = repo.findAllById(nonNullIds)
.stream()
.collect(Collectors.toMap(Identified::getId,
Expand Down

0 comments on commit 5907952

Please sign in to comment.