Use String.isEmpty instead of length

This commit is contained in:
Tran Ngoc Nhan
2024-09-22 00:56:28 +07:00
committed by GitHub
parent 614ea69526
commit 94d8195a04
3 changed files with 10 additions and 7 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-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.
@@ -29,6 +29,7 @@ import org.springframework.integration.file.remote.session.Session;
*
* @author Gary Russell
* @author Artem Bilan
* @author Ngoc Nhan
*
* @since 3.0
*
@@ -56,7 +57,7 @@ public final class RemoteFileUtils {
List<String> pathsToCreate = new LinkedList<>();
while (nextSeparatorIndex > -1) {
String pathSegment = path.substring(0, nextSeparatorIndex);
if (pathSegment.length() == 0 || session.exists(pathSegment)) {
if (pathSegment.isEmpty() || session.exists(pathSegment)) {
// no more paths to create
break;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-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.xml.DomUtils;
* @author Amol Nayak
* @author Gunnar Hillert
* @author Artem Bilan
* @author Ngoc Nhan
*
* @since 2.2
*/
@@ -99,9 +100,9 @@ public class RetrievingJpaOutboundGatewayParser extends AbstractJpaOutboundGatew
boolean childElementsExist = !CollectionUtils.isEmpty(DomUtils.getChildElementsByTagName(gatewayElement,
"parameter"));
if (others.length() > 0 || childElementsExist) {
if (!others.isEmpty() || childElementsExist) {
parserContext.getReaderContext().error(
(others.length() == 0 ? "" : "'" + others + "' "
(others.isEmpty() ? "" : "'" + others + "' "
+ (childElementsExist ? "and " : ""))
+ (childElementsExist ? "child elements " : "")
+ "not allowed with an 'id-expression' attribute.",

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2022 the original author or authors.
* Copyright 2014-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.
@@ -40,6 +40,7 @@ import org.springframework.xml.xpath.XPathExpressionFactory;
* @author Jonas Partner
* @author Mark Fisher
* @author Artem Bilan
* @author Ngoc Nhan
*
* @since 2.0
*/
@@ -122,7 +123,7 @@ public class XPathExpressionEvaluatingHeaderValueMessageProcessor implements Hea
public Object processMessage(Message<?> message) {
Node node = this.converter.convertToNode(message.getPayload());
Object result = this.evaluationType.evaluateXPath(this.expression, node);
if (result instanceof String && ((String) result).length() == 0) {
if (result instanceof String string && string.isEmpty()) {
result = null;
}
if (result != null && this.headerTypeDescriptor != null) {