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
public Iterator<Node> iterator() {
return new Iterator<Node>() {
return new Iterator<>() {
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");
* 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 {
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;

@ -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");
* you may not use this file except in compliance with the License.
@ -174,7 +174,7 @@ class HealthEndpointConfiguration {
@Override
public Iterator<NamedContributor<HealthContributor>> iterator() {
Iterator<NamedContributor<ReactiveHealthContributor>> iterator = composite.iterator();
return new Iterator<NamedContributor<HealthContributor>>() {
return new Iterator<>() {
@Override
public boolean hasNext() {

@ -70,7 +70,7 @@ class MeterRegistrySpanMetricsTests {
@Test
void registerQueueSizeShouldCreateGauge() {
BlockingQueue<Integer> queue = new ArrayBlockingQueue<Integer>(2);
BlockingQueue<Integer> queue = new ArrayBlockingQueue<>(2);
this.sut.registerQueueSize(queue);
assertThat(getGaugeValue("wavefront.reporter.queue.size")).isZero();
queue.offer(1);
@ -79,7 +79,7 @@ class MeterRegistrySpanMetricsTests {
@Test
void registerQueueRemainingCapacityShouldCreateGauge() {
BlockingQueue<Integer> queue = new ArrayBlockingQueue<Integer>(2);
BlockingQueue<Integer> queue = new ArrayBlockingQueue<>(2);
this.sut.registerQueueRemainingCapacity(queue);
assertThat(getGaugeValue("wavefront.reporter.queue.remaining_capacity")).isEqualTo(2);
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");
* you may not use this file except in compliance with the License.
@ -40,7 +40,7 @@ class CompositeHealthContributorReactiveAdapter implements CompositeReactiveHeal
@Override
public Iterator<NamedContributor<ReactiveHealthContributor>> iterator() {
Iterator<NamedContributor<HealthContributor>> iterator = this.delegate.iterator();
return new Iterator<NamedContributor<ReactiveHealthContributor>>() {
return new Iterator<>() {
@Override
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");
* you may not use this file except in compliance with the License.
@ -95,7 +95,7 @@ class DefaultContributorRegistry<C> implements ContributorRegistry<C> {
@Override
public Iterator<NamedContributor<C>> iterator() {
Iterator<Map.Entry<String, C>> iterator = this.contributors.entrySet().iterator();
return new Iterator<NamedContributor<C>>() {
return new Iterator<>() {
@Override
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");
* 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) {
Assert.notNull(name, "Name must not be null");
Assert.notNull(contributor, "Contributor must not be null");
return new NamedContributor<C>() {
return new NamedContributor<>() {
@Override
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");
* 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
public Iterator<NamedContributor<C>> iterator() {
Iterator<Entry<String, C>> iterator = this.map.entrySet().iterator();
return new Iterator<NamedContributor<C>>() {
return new Iterator<>() {
@Override
public boolean hasNext() {

@ -102,7 +102,7 @@ abstract class AbstractCacheAutoConfigurationTests {
@Bean
CacheManagerCustomizer<CouchbaseCacheManager> couchbaseCacheManagerCustomizer() {
return new CacheManagerTestCustomizer<CouchbaseCacheManager>() {
return new CacheManagerTestCustomizer<>() {
};
}
@ -130,7 +130,7 @@ abstract class AbstractCacheAutoConfigurationTests {
@Bean
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");
* you may not use this file except in compliance with the License.
@ -523,7 +523,7 @@ class JacksonAutoConfigurationTests {
@Bean
Module jacksonModule() {
SimpleModule module = new SimpleModule();
module.addSerializer(Foo.class, new JsonSerializer<Foo>() {
module.addSerializer(Foo.class, new JsonSerializer<>() {
@Override
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");
* you may not use this file except in compliance with the License.
@ -113,7 +113,7 @@ public class NamedPipeSocket extends Socket {
@Override
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
public void completed(Integer read, A attachment) {

@ -406,7 +406,7 @@ class PropertiesLauncherTests {
}
private Condition<Archive> endingWith(String value) {
return new Condition<Archive>() {
return new Condition<>() {
@Override
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");
* you may not use this file except in compliance with the License.
@ -130,7 +130,7 @@ class MavenBuild {
try {
Path destination = this.temp.toPath();
Path source = this.projectDir.toPath();
Files.walkFileTree(source, new SimpleFileVisitor<Path>() {
Files.walkFileTree(source, new SimpleFileVisitor<>() {
@Override
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");
* 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) {
Assert.notNull(scope, "Scope must not be null");
InstanceSupplier<T> parent = this;
return new InstanceSupplier<T>() {
return new InstanceSupplier<>() {
@Override
public T get(BootstrapContext context) {

@ -814,7 +814,7 @@ class ConfigDataEnvironmentPostProcessorIntegrationTests {
}
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
public boolean matches(ConfigurableEnvironment value) {

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

@ -105,7 +105,7 @@ class SpringConfigurationPropertySourceTests {
@Test
void fromWhenNonEnumerableShouldReturnNonIterable() {
PropertySource<?> propertySource = new PropertySource<Object>("test", new Object()) {
PropertySource<?> propertySource = new PropertySource<>("test", new Object()) {
@Override
public Object getProperty(String name) {
@ -120,7 +120,7 @@ class SpringConfigurationPropertySourceTests {
@Test
void fromWhenEnumerableButRestrictedShouldReturnNonIterable() {
Map<String, Object> source = new LinkedHashMap<String, Object>() {
Map<String, Object> source = new LinkedHashMap<>() {
@Override
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");
* you may not use this file except in compliance with the License.
@ -86,7 +86,7 @@ class ApplicationContextRequestMatcherTests {
@Test
void initializeAndMatchesAreNotCalledIfContextIsIgnored() {
StaticWebApplicationContext context = createWebApplicationContext();
TestApplicationContextRequestMatcher<ApplicationContext> matcher = new TestApplicationContextRequestMatcher<ApplicationContext>(
TestApplicationContextRequestMatcher<ApplicationContext> matcher = new TestApplicationContextRequestMatcher<>(
ApplicationContext.class) {
@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");
* 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) {
String colorString = ESC + "[0;" + color + "m" + string + ESC + "[0m";
return new Condition<String>() {
return new Condition<>() {
@Override
public boolean matches(String value) {

@ -80,7 +80,7 @@ class SampleSessionHazelcastApplicationTests {
headers.set("Authorization", getBasicAuth());
RequestEntity<Object> request = new RequestEntity<>(headers, HttpMethod.GET,
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);
}

@ -115,7 +115,7 @@ class SampleSessionJdbcApplicationTests {
HttpHeaders headers = getHeaders(null);
RequestEntity<Object> request = new RequestEntity<>(headers, HttpMethod.GET,
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);
}

@ -96,7 +96,7 @@ class SampleSessionRedisApplicationTests {
private ResponseEntity<Map<String, Object>> getSessions() {
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);
}

@ -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");
* you may not use this file except in compliance with the License.
@ -31,7 +31,7 @@ public class SampleGroovyTemplateApplication {
@Bean
public Converter<String, Message> messageConverter() {
return new Converter<String, Message>() {
return new Converter<>() {
@Override
public Message convert(String 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");
* you may not use this file except in compliance with the License.
@ -31,7 +31,7 @@ public class SampleWebUiApplication {
@Bean
public Converter<String, Message> messageConverter() {
return new Converter<String, Message>() {
return new Converter<>() {
@Override
public Message convert(String id) {
return messageRepository().findMessage(Long.valueOf(id));

Loading…
Cancel
Save