Modernize code for diamond, isEmpty & pattern matching

This commit is contained in:
Tran Ngoc Nhan
2024-09-24 01:42:38 +07:00
committed by GitHub
parent 40faaa0c15
commit fc377126de
107 changed files with 550 additions and 454 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2020 the original author or authors.
* Copyright 2020-2024 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.
@@ -37,6 +37,7 @@ import org.springframework.util.Assert;
*
* @author Gary Russell
* @author Artem Bilan
* @author Ngoc Nhan
*
* @since 5.4
*
@@ -85,7 +86,7 @@ public class PollableKafkaChannel extends AbstractKafkaChannel
if (isLoggingEnabled()) {
logger.trace(() -> "preReceive on channel '" + this + "'");
}
if (interceptorList.getInterceptors().size() > 0) {
if (!interceptorList.getInterceptors().isEmpty()) {
interceptorStack = new ArrayDeque<>();
if (!interceptorList.preReceive(this, interceptorStack)) {
return null;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2018-2023 the original author or authors.
* Copyright 2018-2024 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.
@@ -104,6 +104,7 @@ import org.springframework.util.StringUtils;
* @author Artem Bilan
* @author Anshul Mehra
* @author Christian Tzolov
* @author Ngoc Nhan
*
* @since 5.4
*
@@ -843,7 +844,7 @@ public class KafkaMessageSource<K, V> extends AbstractMessageSource<Object>
return i.getRecord().offset();
})
.collect(Collectors.toList());
if (rewound.size() > 0) {
if (!rewound.isEmpty()) {
this.logger.warn(() -> "Rolled back " + KafkaUtils.format(record)
+ " later in-flight offsets "
+ rewound + " will also be re-fetched");
@@ -875,7 +876,7 @@ public class KafkaMessageSource<K, V> extends AbstractMessageSource<Object>
}
}
}
if (toCommit.size() > 0) {
if (!toCommit.isEmpty()) {
ackInformation = toCommit.get(toCommit.size() - 1);
KafkaAckInfo<K, V> ackInformationToLog = ackInformation;
this.commitLogger.log(() -> "Committing pending offsets for "