From c4ae269b143ea52be4f217c70616da63b4beb274 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 cf0d696ef..b00ca61a3 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 @@ -98,7 +98,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) { @@ -212,6 +212,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())))); }