From 103de476cd4428c824cd93481c3584d19c694e48 Mon Sep 17 00:00:00 2001 From: Oliver Drotbohm Date: Thu, 6 Dec 2018 17:45:06 +0100 Subject: [PATCH] DATAMONGO-2155 - Polishing. Original pull request: #625. --- .../mongodb/core/convert/QueryMapper.java | 21 ++++++------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/QueryMapper.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/QueryMapper.java index 7bf59bcf7..16b7b0d7d 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/QueryMapper.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/QueryMapper.java @@ -15,17 +15,8 @@ */ package org.springframework.data.mongodb.core.convert; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.Map.Entry; -import java.util.Optional; -import java.util.Set; import org.bson.BsonValue; import org.bson.Document; @@ -431,6 +422,7 @@ public class QueryMapper { * @return */ @Nullable + @SuppressWarnings("unchecked") protected Object convertSimpleOrDocument(Object source, @Nullable MongoPersistentEntity entity) { if (source instanceof List) { @@ -455,7 +447,7 @@ public class QueryMapper { if (source instanceof Map) { - LinkedHashMap map = new LinkedHashMap<>(); + Map map = new LinkedHashMap<>(); ((Map) source).entrySet().forEach(it -> { @@ -467,6 +459,7 @@ public class QueryMapper { map.put(key, delegateConvertToMongoType(it.getValue(), entity)); } }); + return map; } @@ -656,12 +649,12 @@ public class QueryMapper { static class Keyword { private static final String N_OR_PATTERN = "\\$.*or"; - private static final Set NON_DBREF_CONVERTING_KEYWORDS = new HashSet<>(Arrays.asList("$", "$size", "$slice", "$gt", "$lt")); + private static final Set NON_DBREF_CONVERTING_KEYWORDS = new HashSet<>( + Arrays.asList("$", "$size", "$slice", "$gt", "$lt")); private final String key; private final Object value; - public Keyword(Bson source, String key) { this.key = key; this.value = BsonUtils.get(source, key); @@ -723,7 +716,6 @@ public class QueryMapper { } /** - * * @return {@literal true} if key may hold a DbRef. * @since 2.1.4 */ @@ -842,7 +834,6 @@ public class QueryMapper { * * @return {@literal true} if property information is available and references a {@link java.util.Map}. * @see PersistentProperty#isMap() - * @since 2.2 */ public boolean isMap() { return getProperty() != null && getProperty().isMap();