Skip to content

Commit aaf5858

Browse files
committed
Polishing.
Reformat code. Original pull request: #2314. Closes: #2313
1 parent 8f4beff commit aaf5858

File tree

2 files changed

+23
-26
lines changed

2 files changed

+23
-26
lines changed

src/main/java/org/springframework/data/util/TypeDiscoverer.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ public List<TypeInformation<?>> getParameterTypes(Constructor<?> constructor) {
177177
Assert.notNull(constructor, "Constructor must not be null!");
178178

179179
List<TypeInformation<?>> parameterTypes = new ArrayList<>(constructor.getParameterCount());
180-
for(Parameter parameter : constructor.getParameters()) {
180+
for (Parameter parameter : constructor.getParameters()) {
181181
parameterTypes.add(createInfo(parameter.getParameterizedType()));
182182
}
183183
return parameterTypes;

src/test/java/org/springframework/data/mapping/PreferredConstructorDiscovererUnitTests.java

+22-25
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@
3535
* @author Mark Paluch
3636
* @author Christoph Strobl
3737
*/
38-
public class PreferredConstructorDiscovererUnitTests<P extends PersistentProperty<P>> {
38+
class PreferredConstructorDiscovererUnitTests<P extends PersistentProperty<P>> {
3939

4040
@Test // DATACMNS-1126
41-
public void findsNoArgConstructorForClassWithoutExplicitConstructor() {
41+
void findsNoArgConstructorForClassWithoutExplicitConstructor() {
4242

4343
assertThat(PreferredConstructorDiscoverer.discover(EntityWithoutConstructor.class)).satisfies(constructor -> {
4444

@@ -49,7 +49,7 @@ public void findsNoArgConstructorForClassWithoutExplicitConstructor() {
4949
}
5050

5151
@Test // DATACMNS-1126
52-
public void findsNoArgConstructorForClassWithMultipleConstructorsAndNoArgOne() {
52+
void findsNoArgConstructorForClassWithMultipleConstructorsAndNoArgOne() {
5353

5454
assertThat(PreferredConstructorDiscoverer.discover(ClassWithEmptyConstructor.class)).satisfies(constructor -> {
5555

@@ -60,35 +60,34 @@ public void findsNoArgConstructorForClassWithMultipleConstructorsAndNoArgOne() {
6060
}
6161

6262
@Test // DATACMNS-1126
63-
public void doesNotThrowExceptionForMultipleConstructorsAndNoNoArgConstructorWithoutAnnotation() {
63+
void doesNotThrowExceptionForMultipleConstructorsAndNoNoArgConstructorWithoutAnnotation() {
6464

6565
assertThat(PreferredConstructorDiscoverer.discover(ClassWithMultipleConstructorsWithoutEmptyOne.class)).isNull();
6666
}
6767

6868
@Test // DATACMNS-1126
6969
@SuppressWarnings({ "unchecked", "rawtypes" })
70-
public void usesConstructorWithAnnotationOverEveryOther() {
71-
70+
void usesConstructorWithAnnotationOverEveryOther() {
7271

7372
assertThat(PreferredConstructorDiscoverer.discover(ClassWithMultipleConstructorsAndAnnotation.class))
7473
.satisfies(constructor -> {
7574

76-
assertThat(constructor).isNotNull();
77-
assertThat(constructor.isNoArgConstructor()).isFalse();
78-
assertThat(constructor.isExplicitlyAnnotated()).isTrue();
75+
assertThat(constructor).isNotNull();
76+
assertThat(constructor.isNoArgConstructor()).isFalse();
77+
assertThat(constructor.isExplicitlyAnnotated()).isTrue();
7978

80-
assertThat(constructor.hasParameters()).isTrue();
79+
assertThat(constructor.hasParameters()).isTrue();
8180

8281
Iterator<Parameter<Object, P>> parameters = (Iterator) constructor.getParameters().iterator();
8382

84-
Parameter<?, P> parameter = parameters.next();
85-
assertThat(parameter.getType().getType()).isEqualTo(Long.class);
86-
assertThat(parameters.hasNext()).isFalse();
87-
});
83+
Parameter<?, P> parameter = parameters.next();
84+
assertThat(parameter.getType().getType()).isEqualTo(Long.class);
85+
assertThat(parameters.hasNext()).isFalse();
86+
});
8887
}
8988

9089
@Test // DATACMNS-134, DATACMNS-1126
91-
public void discoversInnerClassConstructorCorrectly() {
90+
void discoversInnerClassConstructorCorrectly() {
9291

9392
PersistentEntity<Inner, P> entity = new BasicPersistentEntity<>(ClassTypeInformation.from(Inner.class));
9493

@@ -100,7 +99,7 @@ public void discoversInnerClassConstructorCorrectly() {
10099
}
101100

102101
@Test // DATACMNS-1082, DATACMNS-1126
103-
public void skipsSyntheticConstructor() {
102+
void skipsSyntheticConstructor() {
104103

105104
PersistentEntity<SyntheticConstructor, P> entity = new BasicPersistentEntity<>(
106105
ClassTypeInformation.from(SyntheticConstructor.class));
@@ -116,13 +115,12 @@ public void skipsSyntheticConstructor() {
116115
@Test // GH-2313
117116
void capturesEnclosingTypeParameterOfNonStaticInnerClass() {
118117

119-
assertThat(PreferredConstructorDiscoverer.discover(NonStaticWithGenericTypeArgUsedInCtor.class))
120-
.satisfies(ctor -> {
118+
assertThat(PreferredConstructorDiscoverer.discover(NonStaticWithGenericTypeArgUsedInCtor.class)).satisfies(ctor -> {
121119

122-
assertThat(ctor.getParameters()).hasSize(2);
123-
assertThat(ctor.getParameters().get(0).getName()).isEqualTo("this$0");
124-
assertThat(ctor.getParameters().get(1).getName()).isEqualTo("value");
125-
});
120+
assertThat(ctor.getParameters()).hasSize(2);
121+
assertThat(ctor.getParameters().get(0).getName()).isEqualTo("this$0");
122+
assertThat(ctor.getParameters().get(1).getName()).isEqualTo("value");
123+
});
126124
}
127125

128126
@Test // GH-2313
@@ -150,7 +148,7 @@ class InnerSynthetic {
150148
}
151149
}
152150

153-
static class EntityWithoutConstructor {
151+
private static class EntityWithoutConstructor {
154152

155153
}
156154

@@ -192,10 +190,9 @@ class Inner {
192190

193191
static class GenericTypeArgUsedInCtor<T> {
194192

195-
protected GenericTypeArgUsedInCtor(T value) {}
193+
GenericTypeArgUsedInCtor(T value) {}
196194
}
197195

198-
199196
class NonStaticWithGenericTypeArgUsedInCtor<T> {
200197

201198
protected NonStaticWithGenericTypeArgUsedInCtor(T value) {}

0 commit comments

Comments
 (0)