Browse Source

Polishing.

Add Override annotations and comment why we optimize.
issue/4612
Mark Paluch 2 years ago
parent
commit
583d84fc49
No known key found for this signature in database
GPG Key ID: 55BC6374BAA9D973
  1. 5
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/ReferenceLookupDelegate.java

5
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/ReferenceLookupDelegate.java

@ -240,7 +240,8 @@ public final class ReferenceLookupDelegate {
EvaluationContext evaluationContextFor(MongoPersistentProperty property, Object source, SpELContext spELContext) { EvaluationContext evaluationContextFor(MongoPersistentProperty property, Object source, SpELContext spELContext) {
Object target = source instanceof DocumentReferenceSource documentReferenceSource ? documentReferenceSource.getTargetSource() Object target = source instanceof DocumentReferenceSource documentReferenceSource
? documentReferenceSource.getTargetSource()
: source; : source;
if (target == null) { if (target == null) {
@ -285,6 +286,7 @@ public final class ReferenceLookupDelegate {
Collection<Object> objects = (Collection<Object>) value; Collection<Object> objects = (Collection<Object>) value;
// optimization: bypass query if the collection pointing to the references is empty
if (objects.isEmpty()) { if (objects.isEmpty()) {
return DocumentReferenceQuery.forNoResult(); return DocumentReferenceQuery.forNoResult();
} }
@ -461,6 +463,7 @@ public final class ReferenceLookupDelegate {
return target.stream().sorted((o1, o2) -> compareAgainstReferenceIndex(ors, o1, o2)).collect(Collectors.toList()); return target.stream().sorted((o1, o2) -> compareAgainstReferenceIndex(ors, o1, o2)).collect(Collectors.toList());
} }
@Override
public Document getQuery() { public Document getQuery() {
return query; return query;
} }

Loading…
Cancel
Save