Browse Source

DATAMONGO-2570 - Polishing.

Add assertions. Use method references where possible.

Original pull request: #871.
issue/DATAMONGO-2285
Mark Paluch 6 years ago
parent
commit
c4ae269b14
No known key found for this signature in database
GPG Key ID: 51A00FA751B91849
  1. 4
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/SimpleMongoRepository.java

4
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/SimpleMongoRepository.java

@ -98,7 +98,7 @@ public class SimpleMongoRepository<T, ID> implements MongoRepository<T, ID> {
Assert.notNull(entities, "The given Iterable of entities not be null!"); Assert.notNull(entities, "The given Iterable of entities not be null!");
Streamable<S> source = Streamable.of(entities); Streamable<S> source = Streamable.of(entities);
boolean allNew = source.stream().allMatch(it -> entityInformation.isNew(it)); boolean allNew = source.stream().allMatch(entityInformation::isNew);
if (allNew) { if (allNew) {
@ -212,6 +212,8 @@ public class SimpleMongoRepository<T, ID> implements MongoRepository<T, ID> {
@Override @Override
public Iterable<T> findAllById(Iterable<ID> ids) { public Iterable<T> findAllById(Iterable<ID> ids) {
Assert.notNull(ids, "The given Ids of entities not be null!");
return findAll(new Query(new Criteria(entityInformation.getIdAttribute()) return findAll(new Query(new Criteria(entityInformation.getIdAttribute())
.in(Streamable.of(ids).stream().collect(StreamUtils.toUnmodifiableList())))); .in(Streamable.of(ids).stream().collect(StreamUtils.toUnmodifiableList()))));
} }

Loading…
Cancel
Save