Skip to content

Commit 94d8195

Browse files
Use String.isEmpty instead of length
1 parent 614ea69 commit 94d8195

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

spring-integration-file/src/main/java/org/springframework/integration/file/remote/RemoteFileUtils.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,6 +29,7 @@
2929
*
3030
* @author Gary Russell
3131
* @author Artem Bilan
32+
* @author Ngoc Nhan
3233
*
3334
* @since 3.0
3435
*
@@ -56,7 +57,7 @@ public static <F> void makeDirectories(String path, Session<F> session, String r
5657
List<String> pathsToCreate = new LinkedList<>();
5758
while (nextSeparatorIndex > -1) {
5859
String pathSegment = path.substring(0, nextSeparatorIndex);
59-
if (pathSegment.length() == 0 || session.exists(pathSegment)) {
60+
if (pathSegment.isEmpty() || session.exists(pathSegment)) {
6061
// no more paths to create
6162
break;
6263
}

spring-integration-jpa/src/main/java/org/springframework/integration/jpa/config/xml/RetrievingJpaOutboundGatewayParser.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -37,6 +37,7 @@
3737
* @author Amol Nayak
3838
* @author Gunnar Hillert
3939
* @author Artem Bilan
40+
* @author Ngoc Nhan
4041
*
4142
* @since 2.2
4243
*/
@@ -99,9 +100,9 @@ private static void parseIdExpression(Element gatewayElement, ParserContext pars
99100

100101
boolean childElementsExist = !CollectionUtils.isEmpty(DomUtils.getChildElementsByTagName(gatewayElement,
101102
"parameter"));
102-
if (others.length() > 0 || childElementsExist) {
103+
if (!others.isEmpty() || childElementsExist) {
103104
parserContext.getReaderContext().error(
104-
(others.length() == 0 ? "" : "'" + others + "' "
105+
(others.isEmpty() ? "" : "'" + others + "' "
105106
+ (childElementsExist ? "and " : ""))
106107
+ (childElementsExist ? "child elements " : "")
107108
+ "not allowed with an 'id-expression' attribute.",

spring-integration-xml/src/main/java/org/springframework/integration/xml/transformer/support/XPathExpressionEvaluatingHeaderValueMessageProcessor.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2022 the original author or authors.
2+
* Copyright 2014-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -40,6 +40,7 @@
4040
* @author Jonas Partner
4141
* @author Mark Fisher
4242
* @author Artem Bilan
43+
* @author Ngoc Nhan
4344
*
4445
* @since 2.0
4546
*/
@@ -122,7 +123,7 @@ public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
122123
public Object processMessage(Message<?> message) {
123124
Node node = this.converter.convertToNode(message.getPayload());
124125
Object result = this.evaluationType.evaluateXPath(this.expression, node);
125-
if (result instanceof String && ((String) result).length() == 0) {
126+
if (result instanceof String string && string.isEmpty()) {
126127
result = null;
127128
}
128129
if (result != null && this.headerTypeDescriptor != null) {

0 commit comments

Comments
 (0)