Browse Source

DATAMONGO-2155 - Polishing.

Original pull request: #625.
pull/635/head
Oliver Drotbohm 7 years ago committed by Mark Paluch
parent
commit
103de476cd
  1. 21
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/QueryMapper.java

21
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; package org.springframework.data.mongodb.core.convert;
import java.util.ArrayList; import java.util.*;
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.Map.Entry; import java.util.Map.Entry;
import java.util.Optional;
import java.util.Set;
import org.bson.BsonValue; import org.bson.BsonValue;
import org.bson.Document; import org.bson.Document;
@ -431,6 +422,7 @@ public class QueryMapper {
* @return * @return
*/ */
@Nullable @Nullable
@SuppressWarnings("unchecked")
protected Object convertSimpleOrDocument(Object source, @Nullable MongoPersistentEntity<?> entity) { protected Object convertSimpleOrDocument(Object source, @Nullable MongoPersistentEntity<?> entity) {
if (source instanceof List) { if (source instanceof List) {
@ -455,7 +447,7 @@ public class QueryMapper {
if (source instanceof Map) { if (source instanceof Map) {
LinkedHashMap<String, Object> map = new LinkedHashMap<>(); Map<String, Object> map = new LinkedHashMap<>();
((Map<String, Object>) source).entrySet().forEach(it -> { ((Map<String, Object>) source).entrySet().forEach(it -> {
@ -467,6 +459,7 @@ public class QueryMapper {
map.put(key, delegateConvertToMongoType(it.getValue(), entity)); map.put(key, delegateConvertToMongoType(it.getValue(), entity));
} }
}); });
return map; return map;
} }
@ -656,12 +649,12 @@ public class QueryMapper {
static class Keyword { static class Keyword {
private static final String N_OR_PATTERN = "\\$.*or"; private static final String N_OR_PATTERN = "\\$.*or";
private static final Set<String> NON_DBREF_CONVERTING_KEYWORDS = new HashSet<>(Arrays.asList("$", "$size", "$slice", "$gt", "$lt")); private static final Set<String> NON_DBREF_CONVERTING_KEYWORDS = new HashSet<>(
Arrays.asList("$", "$size", "$slice", "$gt", "$lt"));
private final String key; private final String key;
private final Object value; private final Object value;
public Keyword(Bson source, String key) { public Keyword(Bson source, String key) {
this.key = key; this.key = key;
this.value = BsonUtils.get(source, key); this.value = BsonUtils.get(source, key);
@ -723,7 +716,6 @@ public class QueryMapper {
} }
/** /**
*
* @return {@literal true} if key may hold a DbRef. * @return {@literal true} if key may hold a DbRef.
* @since 2.1.4 * @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}. * @return {@literal true} if property information is available and references a {@link java.util.Map}.
* @see PersistentProperty#isMap() * @see PersistentProperty#isMap()
* @since 2.2
*/ */
public boolean isMap() { public boolean isMap() {
return getProperty() != null && getProperty().isMap(); return getProperty() != null && getProperty().isMap();

Loading…
Cancel
Save