Use diamond operator where feasible

See gh-31916
This commit is contained in:
Yanming Zhou
2023-12-28 15:25:18 +08:00
committed by Stéphane Nicoll
parent db2c532c07
commit 094479b55f
22 changed files with 54 additions and 35 deletions

View File

@@ -60,7 +60,8 @@ class DefaultEntityResponseBuilderTests {
void fromObjectTypeReference() {
String body = "foo";
EntityResponse<String> response = EntityResponse.fromObject(body,
new ParameterizedTypeReference<String>() {})
new ParameterizedTypeReference<>() {
})
.build();
assertThat(response.entity()).isSameAs(body);

View File

@@ -265,7 +265,8 @@ class DefaultServerRequestTests {
DefaultServerRequest request = new DefaultServerRequest(servletRequest,
List.of(new MappingJackson2HttpMessageConverter()));
List<String> result = request.body(new ParameterizedTypeReference<List<String>>() {});
List<String> result = request.body(new ParameterizedTypeReference<>() {
});
assertThat(result).hasSize(2);
assertThat(result).element(0).isEqualTo("foo");
assertThat(result).element(1).isEqualTo("bar");

View File

@@ -293,7 +293,8 @@ class DefaultServerResponseBuilderTests {
List<String> body = new ArrayList<>();
body.add("foo");
body.add("bar");
ServerResponse response = ServerResponse.ok().body(body, new ParameterizedTypeReference<List<String>>() {});
ServerResponse response = ServerResponse.ok().body(body, new ParameterizedTypeReference<>() {
});
MockHttpServletRequest mockRequest = new MockHttpServletRequest("GET", "https://example.com");
MockHttpServletResponse mockResponse = new MockHttpServletResponse();

View File

@@ -291,7 +291,7 @@ class ViewResolverTests {
request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, this.wac);
request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, new AcceptHeaderLocaleResolver());
View view = vr.resolveViewName("example1", Locale.getDefault());
view.render(new HashMap<String, Object>(), request, this.response);
view.render(new HashMap<>(), request, this.response);
}
@Test
@@ -327,7 +327,7 @@ class ViewResolverTests {
request.setAttribute(DispatcherServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, this.wac);
request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, new AcceptHeaderLocaleResolver());
View view = vr.resolveViewName("example1", Locale.getDefault());
view.render(new HashMap<String, Object>(), request, this.response);
view.render(new HashMap<>(), request, this.response);
}
@Test