Skip to content

Commit c85f371

Browse files
committed
Polishing.
Reformat code. See #3998
1 parent 7ce2143 commit c85f371

File tree

2 files changed

+30
-36
lines changed

2 files changed

+30
-36
lines changed

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

+3-6
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,7 @@ public <R> R project(EntityProjection<R, ?> projection, Bson bson) {
324324
}
325325

326326
@SuppressWarnings("unchecked")
327-
private <R> R doReadProjection(ConversionContext context, Bson bson,
328-
EntityProjection<R, ?> projection) {
327+
private <R> R doReadProjection(ConversionContext context, Bson bson, EntityProjection<R, ?> projection) {
329328

330329
MongoPersistentEntity<?> entity = getMappingContext().getRequiredPersistentEntity(projection.getActualDomainType());
331330
TypeInformation<?> mappedType = projection.getActualMappedType();
@@ -657,8 +656,7 @@ private void readProperties(ConversionContext context, MongoPersistentEntity<?>
657656
}
658657

659658
readAssociation(prop.getRequiredAssociation(), accessor, documentAccessor, dbRefProxyHandler, callback,
660-
propertyContext,
661-
evaluator);
659+
propertyContext, evaluator);
662660
continue;
663661
}
664662

@@ -680,8 +678,7 @@ private void readProperties(ConversionContext context, MongoPersistentEntity<?>
680678
}
681679

682680
readAssociation(prop.getRequiredAssociation(), accessor, documentAccessor, dbRefProxyHandler, callback,
683-
propertyContext,
684-
evaluator);
681+
propertyContext, evaluator);
685682
continue;
686683
}
687684

spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/MappingMongoConverterUnitTests.java

+27-30
Original file line numberDiff line numberDiff line change
@@ -2438,7 +2438,6 @@ void shouldUseMostConcreteCustomConversionTargetOnRead() {
24382438
verify(subTypeOfGenericTypeConverter).convert(eq(source));
24392439
}
24402440

2441-
24422441
@Test // GH-3660
24432442
void usesCustomConverterForMapTypesOnWrite() {
24442443

@@ -2482,9 +2481,8 @@ void usesCustomConverterForTypesImplementingMapOnRead() {
24822481
}));
24832482
converter.afterPropertiesSet();
24842483

2485-
org.bson.Document source = new org.bson.Document("1st", "one")
2486-
.append("2nd", 2)
2487-
.append("_class", TypeImplementingMap.class.getName());
2484+
org.bson.Document source = new org.bson.Document("1st", "one").append("2nd", 2).append("_class",
2485+
TypeImplementingMap.class.getName());
24882486

24892487
TypeImplementingMap target = converter.read(TypeImplementingMap.class, source);
24902488

@@ -2519,9 +2517,8 @@ void usesCustomConverterForPropertiesUsingTypesImplementingMapOnRead() {
25192517
converter.afterPropertiesSet();
25202518

25212519
org.bson.Document source = new org.bson.Document("typeImplementingMap",
2522-
new org.bson.Document("1st", "one")
2523-
.append("2nd", 2))
2524-
.append("_class", TypeWrappingTypeImplementingMap.class.getName());
2520+
new org.bson.Document("1st", "one").append("2nd", 2)).append("_class",
2521+
TypeWrappingTypeImplementingMap.class.getName());
25252522

25262523
TypeWrappingTypeImplementingMap target = converter.read(TypeWrappingTypeImplementingMap.class, source);
25272524

@@ -2543,13 +2540,12 @@ void shouldWriteNullPropertyCorrectly() {
25432540
@Test // GH-3686
25442541
void readsCollectionContainingNullValue() {
25452542

2546-
org.bson.Document source = new org.bson.Document("items", Arrays.asList(new org.bson.Document("itemKey", "i1"), null, new org.bson.Document("itemKey", "i3")));
2543+
org.bson.Document source = new org.bson.Document("items",
2544+
Arrays.asList(new org.bson.Document("itemKey", "i1"), null, new org.bson.Document("itemKey", "i3")));
25472545

25482546
Order target = converter.read(Order.class, source);
25492547

2550-
assertThat(target.items)
2551-
.map(it -> it != null ? it.itemKey : null)
2552-
.containsExactly("i1", null, "i3");
2548+
assertThat(target.items).map(it -> it != null ? it.itemKey : null).containsExactly("i1", null, "i3");
25532549
}
25542550

25552551
@Test // GH-3686
@@ -2565,14 +2561,13 @@ void readsArrayContainingNullValue() {
25652561
@Test // GH-3686
25662562
void readsMapContainingNullValue() {
25672563

2568-
org.bson.Document source = new org.bson.Document("mapOfObjects", new org.bson.Document("item1", "i1").append("item2", null).append("item3", "i3"));
2564+
org.bson.Document source = new org.bson.Document("mapOfObjects",
2565+
new org.bson.Document("item1", "i1").append("item2", null).append("item3", "i3"));
25692566

25702567
ClassWithMapProperty target = converter.read(ClassWithMapProperty.class, source);
25712568

2572-
assertThat(target.mapOfObjects)
2573-
.containsEntry("item1", "i1")
2574-
.containsEntry("item2", null)
2575-
.containsEntry("item3", "i3");
2569+
assertThat(target.mapOfObjects).containsEntry("item1", "i1").containsEntry("item2", null).containsEntry("item3",
2570+
"i3");
25762571
}
25772572

25782573
@Test // GH-3670
@@ -2584,7 +2579,7 @@ void appliesCustomConverterEvenToSimpleTypes() {
25842579
}));
25852580
converter.afterPropertiesSet();
25862581

2587-
org.bson.Document source = new org.bson.Document("content", new Binary(new byte[] {0x00, 0x42}));
2582+
org.bson.Document source = new org.bson.Document("content", new Binary(new byte[] { 0x00, 0x42 }));
25882583

25892584
GenericType<Object> target = converter.read(GenericType.class, source);
25902585
assertThat(target.content).isInstanceOf(byte[].class);
@@ -2593,17 +2588,20 @@ void appliesCustomConverterEvenToSimpleTypes() {
25932588
@Test // GH-3702
25942589
void readsRawDocument() {
25952590

2596-
org.bson.Document source = new org.bson.Document("_id", "id-1").append("raw", new org.bson.Document("simple", 1).append("document", new org.bson.Document("inner-doc", 1)));
2591+
org.bson.Document source = new org.bson.Document("_id", "id-1").append("raw",
2592+
new org.bson.Document("simple", 1).append("document", new org.bson.Document("inner-doc", 1)));
25972593

25982594
WithRawDocumentProperties target = converter.read(WithRawDocumentProperties.class, source);
25992595

2600-
assertThat(target.raw).isInstanceOf(org.bson.Document.class).isEqualTo( new org.bson.Document("simple", 1).append("document", new org.bson.Document("inner-doc", 1)));
2596+
assertThat(target.raw).isInstanceOf(org.bson.Document.class)
2597+
.isEqualTo(new org.bson.Document("simple", 1).append("document", new org.bson.Document("inner-doc", 1)));
26012598
}
26022599

26032600
@Test // GH-3702
26042601
void readsListOfRawDocument() {
26052602

2606-
org.bson.Document source = new org.bson.Document("_id", "id-1").append("listOfRaw", Arrays.asList(new org.bson.Document("simple", 1).append("document", new org.bson.Document("inner-doc", 1))));
2603+
org.bson.Document source = new org.bson.Document("_id", "id-1").append("listOfRaw",
2604+
Arrays.asList(new org.bson.Document("simple", 1).append("document", new org.bson.Document("inner-doc", 1))));
26072605

26082606
WithRawDocumentProperties target = converter.read(WithRawDocumentProperties.class, source);
26092607

@@ -2614,11 +2612,12 @@ void readsListOfRawDocument() {
26142612
@Test // GH-3692
26152613
void readsMapThatDoesNotComeAsDocument() {
26162614

2617-
org.bson.Document source = new org.bson.Document("_id", "id-1").append("mapOfObjects", Collections.singletonMap("simple", 1));
2615+
org.bson.Document source = new org.bson.Document("_id", "id-1").append("mapOfObjects",
2616+
Collections.singletonMap("simple", 1));
26182617

26192618
ClassWithMapProperty target = converter.read(ClassWithMapProperty.class, source);
26202619

2621-
assertThat(target.mapOfObjects).containsEntry("simple",1);
2620+
assertThat(target.mapOfObjects).containsEntry("simple", 1);
26222621
}
26232622

26242623
@Test // GH-3851
@@ -2638,7 +2637,8 @@ void readsMapThatDoesNotComeAsDocument() {
26382637

26392638
converter.writePropertyInternal(sourceValue, accessor, persistentProperty);
26402639

2641-
assertThat(accessor.getDocument()).isEqualTo(new org.bson.Document("pName", new org.bson.Document("_id", id.toString())));
2640+
assertThat(accessor.getDocument())
2641+
.isEqualTo(new org.bson.Document("pName", new org.bson.Document("_id", id.toString())));
26422642
}
26432643

26442644
@Test // GH-2860
@@ -2652,8 +2652,7 @@ void projectShouldReadSimpleInterfaceProjection() {
26522652
.and((target, underlyingType) -> !converter.conversions.isSimpleType(target)),
26532653
mappingContext);
26542654

2655-
EntityProjection<PersonProjection, Person> projection = discoverer
2656-
.introspect(PersonProjection.class, Person.class);
2655+
EntityProjection<PersonProjection, Person> projection = discoverer.introspect(PersonProjection.class, Person.class);
26572656
PersonProjection person = converter.project(projection, source);
26582657

26592658
assertThat(person.getBirthDate()).isEqualTo(new LocalDate(1999, 12, 1));
@@ -2671,8 +2670,7 @@ void projectShouldReadSimpleDtoProjection() {
26712670
.and((target, underlyingType) -> !converter.conversions.isSimpleType(target)),
26722671
mappingContext);
26732672

2674-
EntityProjection<PersonDto, Person> projection = introspector
2675-
.introspect(PersonDto.class, Person.class);
2673+
EntityProjection<PersonDto, Person> projection = introspector.introspect(PersonDto.class, Person.class);
26762674
PersonDto person = converter.project(projection, source);
26772675

26782676
assertThat(person.getBirthDate()).isEqualTo(new LocalDate(1999, 12, 1));
@@ -2763,8 +2761,7 @@ interface InterfaceType {
27632761
@EqualsAndHashCode
27642762
@Getter
27652763
static class Address implements InterfaceType {
2766-
@Field("s")
2767-
String street;
2764+
@Field("s") String street;
27682765
String city;
27692766
}
27702767

@@ -3365,7 +3362,7 @@ static class TypeWrappingTypeImplementingMap {
33653362
}
33663363

33673364
@EqualsAndHashCode
3368-
static class TypeImplementingMap implements Map<String,String> {
3365+
static class TypeImplementingMap implements Map<String, String> {
33693366

33703367
String val1;
33713368
int val2;

0 commit comments

Comments
 (0)