Skip to content

Commit 998bd1f

Browse files
committed
Polishing.
Reformat code. Tweak documentation wording and callout syntax. See #3914, see #3901 Original pull request: #3915.
1 parent e0a57fa commit 998bd1f

File tree

4 files changed

+21
-17
lines changed

4 files changed

+21
-17
lines changed

Diff for: spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/IndexResolver.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2021 the original author or authors.
2+
* Copyright 2014-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -33,7 +33,8 @@
3333
* Unless specified otherwise the index name will be created out of the keys/path involved in the index. <br />
3434
* {@link TextIndexed} properties are collected into a single index that covers the detected fields. <br />
3535
* {@link java.util.Map} like structures, unless annotated with {@link WildcardIndexed}, are skipped because the
36-
* {@link java.util.Map.Entry#getKey() map key}, which cannot be resolved from static metadata, needs to be part of the index.
36+
* {@link java.util.Map.Entry#getKey() map key}, which cannot be resolved from static metadata, needs to be part of the
37+
* index.
3738
*
3839
* @author Christoph Strobl
3940
* @author Thomas Darimont

Diff for: spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/MongoPersistentEntityIndexResolver.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2021 the original author or authors.
2+
* Copyright 2014-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -174,7 +174,7 @@ private void potentiallyAddIndexForProperty(MongoPersistentEntity<?> root, Mongo
174174
indexes.addAll(indexDefinitions);
175175
}
176176
} catch (CyclicPropertyReferenceException e) {
177-
if(LOGGER.isInfoEnabled()) {
177+
if (LOGGER.isInfoEnabled()) {
178178
LOGGER.info(e.getMessage());
179179
}
180180
}
@@ -357,7 +357,7 @@ public void doWithPersistentProperty(MongoPersistentProperty persistentProperty)
357357
indexDefinitionBuilder.withLanguageOverride(persistentProperty.getFieldName());
358358
}
359359

360-
if(persistentProperty.isMap()) {
360+
if (persistentProperty.isMap()) {
361361
return;
362362
}
363363

Diff for: spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/index/MongoPersistentEntityIndexResolverUnitTests.java

+12-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2021 the original author or authors.
2+
* Copyright 2014-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -319,7 +319,8 @@ class IndexOnLevelOneWithExplicitlyNamedField {
319319

320320
class IndexOnLevelZeroWithExplicityNamedField {
321321

322-
@Indexed @Field("customFieldName") String namedProperty;
322+
@Indexed
323+
@Field("customFieldName") String namedProperty;
323324
}
324325

325326
@Document
@@ -427,7 +428,8 @@ class WithPartialFilter {
427428

428429
@Document
429430
class IndexOnMetaAnnotatedField {
430-
@Field("_name") @IndexedFieldAnnotation String lastname;
431+
@Field("_name")
432+
@IndexedFieldAnnotation String lastname;
431433
}
432434

433435
/**
@@ -1366,10 +1368,9 @@ public void resolvesWildcardOnProperty() {
13661368
});
13671369
assertThat(indices.get(2)).satisfies(it -> {
13681370
assertThat(it.getIndexKeys()).containsEntry("withOptions.$**", 1);
1369-
assertThat(it.getIndexOptions()).containsEntry("name",
1370-
"withOptions.idx")
1371-
.containsEntry("collation", new org.bson.Document("locale", "en_US"))
1372-
.containsEntry("partialFilterExpression", new org.bson.Document("$eq", 1));
1371+
assertThat(it.getIndexOptions()).containsEntry("name", "withOptions.idx")
1372+
.containsEntry("collation", new org.bson.Document("locale", "en_US"))
1373+
.containsEntry("partialFilterExpression", new org.bson.Document("$eq", 1));
13731374
});
13741375
}
13751376

@@ -1491,7 +1492,8 @@ class ValueObject {
14911492
@Document
14921493
class SimilarityHolingBean {
14931494

1494-
@Indexed @Field("norm") String normalProperty;
1495+
@Indexed
1496+
@Field("norm") String normalProperty;
14951497
@Field("similarityL") private List<SimilaritySibling> listOfSimilarilyNamedEntities = null;
14961498
}
14971499

@@ -1654,7 +1656,8 @@ class EntityWithGenericTypeWrapperAsElement {
16541656
@Document
16551657
class WithHashedIndexOnId {
16561658

1657-
@HashIndexed @Id String id;
1659+
@HashIndexed
1660+
@Id String id;
16581661
}
16591662

16601663
@Document

Diff for: src/main/asciidoc/reference/mapping.adoc

+3-3
Original file line numberDiff line numberDiff line change
@@ -409,9 +409,9 @@ This event guarantees that the context is fully initialized.
409409
Note that at this time other components, especially bean factories might have access to the MongoDB database.
410410

411411
[WARNING]
412-
===
413-
`Map` like structures, unless annotated with `@WildcardIndexed`, are skipped by the `IndexResolver` because the _map key_, which cannot be resolved from static metadata, needs to be part of the index definition.
414-
===
412+
====
413+
``Map``-like properties are skipped by the `IndexResolver` unless annotated with `@WildcardIndexed` because the _map key_ must be part of the index definition. Since the purpose of maps is the usage of dynamic keys and values, the keys cannot be resolved from static mapping metadata.
414+
====
415415

416416
.Programmatic Index Creation for a single Domain Type
417417
====

0 commit comments

Comments
 (0)