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 6d58b216f..8aa2a30e6 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 @@ -132,10 +132,8 @@ public class QueryMapper { // TODO: remove one once QueryMapper can work with Query instances directly if (Query.isRestrictedTypeKey(key)) { - @SuppressWarnings("unchecked") Set> restrictedTypes = BsonUtils.get(query, key); this.converter.getTypeMapper().writeTypeRestrictions(result, restrictedTypes); - continue; } @@ -282,7 +280,7 @@ public class QueryMapper { if (keyword.isOrOrNor() || (keyword.hasIterableValue() && !keyword.isGeometry())) { Iterable conditions = keyword.getValue(); - List newConditions = new ArrayList(); + List newConditions = new ArrayList<>(); for (Object condition : conditions) { newConditions.add(isDocument(condition) ? getMappedObject((Document) condition, entity) @@ -293,11 +291,12 @@ public class QueryMapper { } if (keyword.isSample()) { - return exampleMapper.getMappedExample(keyword.> getValue(), entity); + return exampleMapper.getMappedExample(keyword.getValue(), entity); } if (keyword.isJsonSchema()) { - return schemaMapper.mapSchema(new Document(keyword.getKey(), keyword.getValue()), entity != null ? entity.getType() : Object.class); + return schemaMapper.mapSchema(new Document(keyword.getKey(), keyword.getValue()), + entity != null ? entity.getType() : Object.class); } return new Document(keyword.getKey(), convertSimpleOrDocument(keyword.getValue(), entity)); @@ -318,7 +317,7 @@ public class QueryMapper { Object convertedValue = needsAssociationConversion ? convertAssociation(value, property) : getMappedValue(property.with(keyword.getKey()), value); - if(keyword.isSample() && convertedValue instanceof Document) { + if (keyword.isSample() && convertedValue instanceof Document) { return (Document) convertedValue; } @@ -337,8 +336,8 @@ public class QueryMapper { @SuppressWarnings("unchecked") protected Object getMappedValue(Field documentField, Object value) { - if(documentField.getProperty() != null && documentField.getProperty().hasExplicitWriteTarget()) { - if(conversionService.canConvert(value.getClass(), documentField.getProperty().getFieldType())) { + if (documentField.getProperty() != null && documentField.getProperty().hasExplicitWriteTarget()) { + if (conversionService.canConvert(value.getClass(), documentField.getProperty().getFieldType())) { value = conversionService.convert(value, documentField.getProperty().getFieldType()); } } @@ -351,7 +350,7 @@ public class QueryMapper { if (valueDbo.containsField("$in") || valueDbo.containsField("$nin")) { String inKey = valueDbo.containsField("$in") ? "$in" : "$nin"; - List ids = new ArrayList(); + List ids = new ArrayList<>(); for (Object id : (Iterable) valueDbo.get(inKey)) { ids.add(convertId(id, getIdTypeForField(documentField))); } @@ -370,7 +369,7 @@ public class QueryMapper { if (valueDbo.containsKey("$in") || valueDbo.containsKey("$nin")) { String inKey = valueDbo.containsKey("$in") ? "$in" : "$nin"; - List ids = new ArrayList(); + List ids = new ArrayList<>(); for (Object id : (Iterable) valueDbo.get(inKey)) { ids.add(convertId(id, getIdTypeForField(documentField))); } @@ -451,8 +450,8 @@ public class QueryMapper { @SuppressWarnings("unchecked") protected Object convertSimpleOrDocument(Object source, @Nullable MongoPersistentEntity entity) { - if(source instanceof Example) { - return exampleMapper.getMappedExample((Example)source, entity); + if (source instanceof Example) { + return exampleMapper.getMappedExample((Example) source, entity); } if (source instanceof List) {