Use diamond operators

See gh-33987
pull/34001/head
Krzysztof Krason 2 years ago committed by Phillip Webb
parent 5120242996
commit 6e46423983

@ -132,7 +132,7 @@ class PluginXmlParser {
@Override @Override
public Iterator<Node> iterator() { public Iterator<Node> iterator() {
return new Iterator<Node>() { return new Iterator<>() {
private int index = 0; private int index = 0;

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -46,7 +46,7 @@ import org.springframework.web.reactive.function.client.WebClientResponseExcepti
*/ */
class ReactiveCloudFoundrySecurityService { class ReactiveCloudFoundrySecurityService {
private static final ParameterizedTypeReference<Map<String, Object>> STRING_OBJECT_MAP = new ParameterizedTypeReference<Map<String, Object>>() { private static final ParameterizedTypeReference<Map<String, Object>> STRING_OBJECT_MAP = new ParameterizedTypeReference<>() {
}; };
private final WebClient webClient; private final WebClient webClient;

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -174,7 +174,7 @@ class HealthEndpointConfiguration {
@Override @Override
public Iterator<NamedContributor<HealthContributor>> iterator() { public Iterator<NamedContributor<HealthContributor>> iterator() {
Iterator<NamedContributor<ReactiveHealthContributor>> iterator = composite.iterator(); Iterator<NamedContributor<ReactiveHealthContributor>> iterator = composite.iterator();
return new Iterator<NamedContributor<HealthContributor>>() { return new Iterator<>() {
@Override @Override
public boolean hasNext() { public boolean hasNext() {

@ -70,7 +70,7 @@ class MeterRegistrySpanMetricsTests {
@Test @Test
void registerQueueSizeShouldCreateGauge() { void registerQueueSizeShouldCreateGauge() {
BlockingQueue<Integer> queue = new ArrayBlockingQueue<Integer>(2); BlockingQueue<Integer> queue = new ArrayBlockingQueue<>(2);
this.sut.registerQueueSize(queue); this.sut.registerQueueSize(queue);
assertThat(getGaugeValue("wavefront.reporter.queue.size")).isZero(); assertThat(getGaugeValue("wavefront.reporter.queue.size")).isZero();
queue.offer(1); queue.offer(1);
@ -79,7 +79,7 @@ class MeterRegistrySpanMetricsTests {
@Test @Test
void registerQueueRemainingCapacityShouldCreateGauge() { void registerQueueRemainingCapacityShouldCreateGauge() {
BlockingQueue<Integer> queue = new ArrayBlockingQueue<Integer>(2); BlockingQueue<Integer> queue = new ArrayBlockingQueue<>(2);
this.sut.registerQueueRemainingCapacity(queue); this.sut.registerQueueRemainingCapacity(queue);
assertThat(getGaugeValue("wavefront.reporter.queue.remaining_capacity")).isEqualTo(2); assertThat(getGaugeValue("wavefront.reporter.queue.remaining_capacity")).isEqualTo(2);
queue.offer(1); queue.offer(1);

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -40,7 +40,7 @@ class CompositeHealthContributorReactiveAdapter implements CompositeReactiveHeal
@Override @Override
public Iterator<NamedContributor<ReactiveHealthContributor>> iterator() { public Iterator<NamedContributor<ReactiveHealthContributor>> iterator() {
Iterator<NamedContributor<HealthContributor>> iterator = this.delegate.iterator(); Iterator<NamedContributor<HealthContributor>> iterator = this.delegate.iterator();
return new Iterator<NamedContributor<ReactiveHealthContributor>>() { return new Iterator<>() {
@Override @Override
public boolean hasNext() { public boolean hasNext() {

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -95,7 +95,7 @@ class DefaultContributorRegistry<C> implements ContributorRegistry<C> {
@Override @Override
public Iterator<NamedContributor<C>> iterator() { public Iterator<NamedContributor<C>> iterator() {
Iterator<Map.Entry<String, C>> iterator = this.contributors.entrySet().iterator(); Iterator<Map.Entry<String, C>> iterator = this.contributors.entrySet().iterator();
return new Iterator<NamedContributor<C>>() { return new Iterator<>() {
@Override @Override
public boolean hasNext() { public boolean hasNext() {

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -44,7 +44,7 @@ public interface NamedContributor<C> {
static <C> NamedContributor<C> of(String name, C contributor) { static <C> NamedContributor<C> of(String name, C contributor) {
Assert.notNull(name, "Name must not be null"); Assert.notNull(name, "Name must not be null");
Assert.notNull(contributor, "Contributor must not be null"); Assert.notNull(contributor, "Contributor must not be null");
return new NamedContributor<C>() { return new NamedContributor<>() {
@Override @Override
public String getName() { public String getName() {

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -62,7 +62,7 @@ abstract class NamedContributorsMapAdapter<V, C> implements NamedContributors<C>
@Override @Override
public Iterator<NamedContributor<C>> iterator() { public Iterator<NamedContributor<C>> iterator() {
Iterator<Entry<String, C>> iterator = this.map.entrySet().iterator(); Iterator<Entry<String, C>> iterator = this.map.entrySet().iterator();
return new Iterator<NamedContributor<C>>() { return new Iterator<>() {
@Override @Override
public boolean hasNext() { public boolean hasNext() {

@ -102,7 +102,7 @@ abstract class AbstractCacheAutoConfigurationTests {
@Bean @Bean
CacheManagerCustomizer<CouchbaseCacheManager> couchbaseCacheManagerCustomizer() { CacheManagerCustomizer<CouchbaseCacheManager> couchbaseCacheManagerCustomizer() {
return new CacheManagerTestCustomizer<CouchbaseCacheManager>() { return new CacheManagerTestCustomizer<>() {
}; };
} }
@ -130,7 +130,7 @@ abstract class AbstractCacheAutoConfigurationTests {
@Bean @Bean
CacheManagerCustomizer<SpringCache2kCacheManager> cache2kCacheManagerCustomizer() { CacheManagerCustomizer<SpringCache2kCacheManager> cache2kCacheManagerCustomizer() {
return new CacheManagerTestCustomizer<SpringCache2kCacheManager>() { return new CacheManagerTestCustomizer<>() {
}; };
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -523,7 +523,7 @@ class JacksonAutoConfigurationTests {
@Bean @Bean
Module jacksonModule() { Module jacksonModule() {
SimpleModule module = new SimpleModule(); SimpleModule module = new SimpleModule();
module.addSerializer(Foo.class, new JsonSerializer<Foo>() { module.addSerializer(Foo.class, new JsonSerializer<>() {
@Override @Override
public void serialize(Foo value, JsonGenerator jgen, SerializerProvider provider) throws IOException { public void serialize(Foo value, JsonGenerator jgen, SerializerProvider provider) throws IOException {

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -113,7 +113,7 @@ public class NamedPipeSocket extends Socket {
@Override @Override
public <A> void read(ByteBuffer dst, A attachment, CompletionHandler<Integer, ? super A> handler) { public <A> void read(ByteBuffer dst, A attachment, CompletionHandler<Integer, ? super A> handler) {
this.fileChannel.read(dst, 0, attachment, new CompletionHandler<Integer, A>() { this.fileChannel.read(dst, 0, attachment, new CompletionHandler<>() {
@Override @Override
public void completed(Integer read, A attachment) { public void completed(Integer read, A attachment) {

@ -406,7 +406,7 @@ class PropertiesLauncherTests {
} }
private Condition<Archive> endingWith(String value) { private Condition<Archive> endingWith(String value) {
return new Condition<Archive>() { return new Condition<>() {
@Override @Override
public boolean matches(Archive archive) { public boolean matches(Archive archive) {

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -130,7 +130,7 @@ class MavenBuild {
try { try {
Path destination = this.temp.toPath(); Path destination = this.temp.toPath();
Path source = this.projectDir.toPath(); Path source = this.projectDir.toPath();
Files.walkFileTree(source, new SimpleFileVisitor<Path>() { Files.walkFileTree(source, new SimpleFileVisitor<>() {
@Override @Override
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -123,7 +123,7 @@ public interface BootstrapRegistry {
default InstanceSupplier<T> withScope(Scope scope) { default InstanceSupplier<T> withScope(Scope scope) {
Assert.notNull(scope, "Scope must not be null"); Assert.notNull(scope, "Scope must not be null");
InstanceSupplier<T> parent = this; InstanceSupplier<T> parent = this;
return new InstanceSupplier<T>() { return new InstanceSupplier<>() {
@Override @Override
public T get(BootstrapContext context) { public T get(BootstrapContext context) {

@ -814,7 +814,7 @@ class ConfigDataEnvironmentPostProcessorIntegrationTests {
} }
private Condition<ConfigurableEnvironment> matchingPropertySource(final String sourceName) { private Condition<ConfigurableEnvironment> matchingPropertySource(final String sourceName) {
return new Condition<ConfigurableEnvironment>("environment containing property source " + sourceName) { return new Condition<>("environment containing property source " + sourceName) {
@Override @Override
public boolean matches(ConfigurableEnvironment value) { public boolean matches(ConfigurableEnvironment value) {

@ -507,7 +507,7 @@ class JavaBeanBinderTests {
void beanPropertiesPreferMatchingType() { void beanPropertiesPreferMatchingType() {
// gh-16206 // gh-16206
ResolvableType type = ResolvableType.forClass(PropertyWithOverloadedSetter.class); ResolvableType type = ResolvableType.forClass(PropertyWithOverloadedSetter.class);
Bean<PropertyWithOverloadedSetter> bean = new Bean<PropertyWithOverloadedSetter>(type, type.resolve()) { Bean<PropertyWithOverloadedSetter> bean = new Bean<>(type, type.resolve()) {
@Override @Override
protected void addProperties(Method[] declaredMethods, Field[] declaredFields) { protected void addProperties(Method[] declaredMethods, Field[] declaredFields) {

@ -105,7 +105,7 @@ class SpringConfigurationPropertySourceTests {
@Test @Test
void fromWhenNonEnumerableShouldReturnNonIterable() { void fromWhenNonEnumerableShouldReturnNonIterable() {
PropertySource<?> propertySource = new PropertySource<Object>("test", new Object()) { PropertySource<?> propertySource = new PropertySource<>("test", new Object()) {
@Override @Override
public Object getProperty(String name) { public Object getProperty(String name) {
@ -120,7 +120,7 @@ class SpringConfigurationPropertySourceTests {
@Test @Test
void fromWhenEnumerableButRestrictedShouldReturnNonIterable() { void fromWhenEnumerableButRestrictedShouldReturnNonIterable() {
Map<String, Object> source = new LinkedHashMap<String, Object>() { Map<String, Object> source = new LinkedHashMap<>() {
@Override @Override
public int size() { public int size() {

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -86,7 +86,7 @@ class ApplicationContextRequestMatcherTests {
@Test @Test
void initializeAndMatchesAreNotCalledIfContextIsIgnored() { void initializeAndMatchesAreNotCalledIfContextIsIgnored() {
StaticWebApplicationContext context = createWebApplicationContext(); StaticWebApplicationContext context = createWebApplicationContext();
TestApplicationContextRequestMatcher<ApplicationContext> matcher = new TestApplicationContextRequestMatcher<ApplicationContext>( TestApplicationContextRequestMatcher<ApplicationContext> matcher = new TestApplicationContextRequestMatcher<>(
ApplicationContext.class) { ApplicationContext.class) {
@Override @Override

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -68,7 +68,7 @@ abstract class AbstractLaunchScriptIntegrationTests {
protected Condition<String> coloredString(AnsiColor color, String string) { protected Condition<String> coloredString(AnsiColor color, String string) {
String colorString = ESC + "[0;" + color + "m" + string + ESC + "[0m"; String colorString = ESC + "[0;" + color + "m" + string + ESC + "[0m";
return new Condition<String>() { return new Condition<>() {
@Override @Override
public boolean matches(String value) { public boolean matches(String value) {

@ -80,7 +80,7 @@ class SampleSessionHazelcastApplicationTests {
headers.set("Authorization", getBasicAuth()); headers.set("Authorization", getBasicAuth());
RequestEntity<Object> request = new RequestEntity<>(headers, HttpMethod.GET, RequestEntity<Object> request = new RequestEntity<>(headers, HttpMethod.GET,
URI.create("/actuator/sessions?username=user")); URI.create("/actuator/sessions?username=user"));
ParameterizedTypeReference<Map<String, Object>> stringObjectMap = new ParameterizedTypeReference<Map<String, Object>>() { ParameterizedTypeReference<Map<String, Object>> stringObjectMap = new ParameterizedTypeReference<>() {
}; };
return this.restTemplate.exchange(request, stringObjectMap); return this.restTemplate.exchange(request, stringObjectMap);
} }

@ -115,7 +115,7 @@ class SampleSessionJdbcApplicationTests {
HttpHeaders headers = getHeaders(null); HttpHeaders headers = getHeaders(null);
RequestEntity<Object> request = new RequestEntity<>(headers, HttpMethod.GET, RequestEntity<Object> request = new RequestEntity<>(headers, HttpMethod.GET,
URI.create("/actuator/sessions?username=user")); URI.create("/actuator/sessions?username=user"));
ParameterizedTypeReference<Map<String, Object>> stringObjectMap = new ParameterizedTypeReference<Map<String, Object>>() { ParameterizedTypeReference<Map<String, Object>> stringObjectMap = new ParameterizedTypeReference<>() {
}; };
return this.restTemplate.exchange(request, stringObjectMap); return this.restTemplate.exchange(request, stringObjectMap);
} }

@ -96,7 +96,7 @@ class SampleSessionRedisApplicationTests {
private ResponseEntity<Map<String, Object>> getSessions() { private ResponseEntity<Map<String, Object>> getSessions() {
RequestEntity<Object> request = getRequestEntity(URI.create("/actuator/sessions?username=user")); RequestEntity<Object> request = getRequestEntity(URI.create("/actuator/sessions?username=user"));
ParameterizedTypeReference<Map<String, Object>> stringObjectMap = new ParameterizedTypeReference<Map<String, Object>>() { ParameterizedTypeReference<Map<String, Object>> stringObjectMap = new ParameterizedTypeReference<>() {
}; };
return this.restTemplate.exchange(request, stringObjectMap); return this.restTemplate.exchange(request, stringObjectMap);
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -31,7 +31,7 @@ public class SampleGroovyTemplateApplication {
@Bean @Bean
public Converter<String, Message> messageConverter() { public Converter<String, Message> messageConverter() {
return new Converter<String, Message>() { return new Converter<>() {
@Override @Override
public Message convert(String id) { public Message convert(String id) {
return messageRepository().findMessage(Long.valueOf(id)); return messageRepository().findMessage(Long.valueOf(id));

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -31,7 +31,7 @@ public class SampleWebUiApplication {
@Bean @Bean
public Converter<String, Message> messageConverter() { public Converter<String, Message> messageConverter() {
return new Converter<String, Message>() { return new Converter<>() {
@Override @Override
public Message convert(String id) { public Message convert(String id) {
return messageRepository().findMessage(Long.valueOf(id)); return messageRepository().findMessage(Long.valueOf(id));

Loading…
Cancel
Save