From 26e8b3a8ec2d770372f429bb1614e9008e6a40b1 Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Mon, 22 Jun 2020 10:38:54 +0200 Subject: [PATCH] DATAMONGO-2570 - Polishing. Add assertions. Use method references where possible. Original pull request: #871. --- .../mongodb/repository/support/SimpleMongoRepository.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/SimpleMongoRepository.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/SimpleMongoRepository.java index 68b104503..04b804429 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/SimpleMongoRepository.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/SimpleMongoRepository.java @@ -95,7 +95,7 @@ public class SimpleMongoRepository implements MongoRepository { Assert.notNull(entities, "The given Iterable of entities not be null!"); Streamable source = Streamable.of(entities); - boolean allNew = source.stream().allMatch(it -> entityInformation.isNew(it)); + boolean allNew = source.stream().allMatch(entityInformation::isNew); if (allNew) { @@ -202,6 +202,8 @@ public class SimpleMongoRepository implements MongoRepository { @Override public Iterable findAllById(Iterable ids) { + Assert.notNull(ids, "The given Ids of entities not be null!"); + return findAll(new Query(new Criteria(entityInformation.getIdAttribute()) .in(Streamable.of(ids).stream().collect(StreamUtils.toUnmodifiableList())))); }