Skip to content

Commit 8502786

Browse files
committed
DATAMONGO-2314 - Polishing.
Reformat code. Remove unnecessary warning suppressions. Switch to diamond syntax. Original pull request: #771.
1 parent d7107d4 commit 8502786

File tree

1 file changed

+9
-10
lines changed
  • spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert

1 file changed

+9
-10
lines changed

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

+9-10
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,8 @@ public Document getMappedObject(Bson query, @Nullable MongoPersistentEntity<?> e
130130
// TODO: remove one once QueryMapper can work with Query instances directly
131131
if (Query.isRestrictedTypeKey(key)) {
132132

133-
@SuppressWarnings("unchecked")
134133
Set<Class<?>> restrictedTypes = BsonUtils.get(query, key);
135134
this.converter.getTypeMapper().writeTypeRestrictions(result, restrictedTypes);
136-
137135
continue;
138136
}
139137

@@ -271,7 +269,7 @@ protected Document getMappedKeyword(Keyword keyword, @Nullable MongoPersistentEn
271269
if (keyword.isOrOrNor() || (keyword.hasIterableValue() && !keyword.isGeometry())) {
272270

273271
Iterable<?> conditions = keyword.getValue();
274-
List<Object> newConditions = new ArrayList<Object>();
272+
List<Object> newConditions = new ArrayList<>();
275273

276274
for (Object condition : conditions) {
277275
newConditions.add(isDocument(condition) ? getMappedObject((Document) condition, entity)
@@ -282,11 +280,12 @@ protected Document getMappedKeyword(Keyword keyword, @Nullable MongoPersistentEn
282280
}
283281

284282
if (keyword.isSample()) {
285-
return exampleMapper.getMappedExample(keyword.<Example<?>> getValue(), entity);
283+
return exampleMapper.getMappedExample(keyword.getValue(), entity);
286284
}
287285

288286
if (keyword.isJsonSchema()) {
289-
return schemaMapper.mapSchema(new Document(keyword.getKey(), keyword.getValue()), entity != null ? entity.getType() : Object.class);
287+
return schemaMapper.mapSchema(new Document(keyword.getKey(), keyword.getValue()),
288+
entity != null ? entity.getType() : Object.class);
290289
}
291290

292291
return new Document(keyword.getKey(), convertSimpleOrDocument(keyword.getValue(), entity));
@@ -307,7 +306,7 @@ protected Document getMappedKeyword(Field property, Keyword keyword) {
307306
Object convertedValue = needsAssociationConversion ? convertAssociation(value, property)
308307
: getMappedValue(property.with(keyword.getKey()), value);
309308

310-
if(keyword.isSample() && convertedValue instanceof Document) {
309+
if (keyword.isSample() && convertedValue instanceof Document) {
311310
return (Document) convertedValue;
312311
}
313312

@@ -334,7 +333,7 @@ protected Object getMappedValue(Field documentField, Object value) {
334333

335334
if (valueDbo.containsField("$in") || valueDbo.containsField("$nin")) {
336335
String inKey = valueDbo.containsField("$in") ? "$in" : "$nin";
337-
List<Object> ids = new ArrayList<Object>();
336+
List<Object> ids = new ArrayList<>();
338337
for (Object id : (Iterable<?>) valueDbo.get(inKey)) {
339338
ids.add(convertId(id));
340339
}
@@ -353,7 +352,7 @@ else if (isDocument(value)) {
353352

354353
if (valueDbo.containsKey("$in") || valueDbo.containsKey("$nin")) {
355354
String inKey = valueDbo.containsKey("$in") ? "$in" : "$nin";
356-
List<Object> ids = new ArrayList<Object>();
355+
List<Object> ids = new ArrayList<>();
357356
for (Object id : (Iterable<?>) valueDbo.get(inKey)) {
358357
ids.add(convertId(id));
359358
}
@@ -426,8 +425,8 @@ protected boolean isAssociationConversionNecessary(Field documentField, @Nullabl
426425
@SuppressWarnings("unchecked")
427426
protected Object convertSimpleOrDocument(Object source, @Nullable MongoPersistentEntity<?> entity) {
428427

429-
if(source instanceof Example) {
430-
return exampleMapper.getMappedExample((Example)source, entity);
428+
if (source instanceof Example) {
429+
return exampleMapper.getMappedExample((Example) source, entity);
431430
}
432431

433432
if (source instanceof List) {

0 commit comments

Comments
 (0)