Improve String concatenation where appropriate

This commit is contained in:
Mahmoud Ben Hassine
2023-06-05 13:19:28 +02:00
parent 106c4a589d
commit 8070751da8
6 changed files with 26 additions and 24 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2009-2022 the original author or authors.
* Copyright 2009-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.
@@ -34,6 +34,7 @@ import org.w3c.dom.Element;
/**
* @author Dan Garrette
* @author Mahmoud Ben Hassine
* @since 2.0
* @see StepListenerParser
* @see JobExecutionListenerParser
@@ -107,13 +108,13 @@ public abstract class AbstractListenerParser {
found.append("<" + BEAN_ELE + "/> element, ");
}
else if (beanElements.size() > 1) {
found.append(beanElements.size() + " <" + BEAN_ELE + "/> elements, ");
found.append(beanElements.size()).append(" <").append(BEAN_ELE).append("/> elements, ");
}
if (refElements.size() == 1) {
found.append("<" + REF_ELE + "/> element, ");
}
else if (refElements.size() > 1) {
found.append(refElements.size() + " <" + REF_ELE + "/> elements, ");
found.append(refElements.size()).append(" <").append(REF_ELE).append("/> elements, ");
}
found.delete(found.length() - 2, found.length());
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2010 the original author or authors.
* Copyright 2006-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.
@@ -36,6 +36,7 @@ import org.w3c.dom.Element;
* Parse a tasklet element for a step.
*
* @author Dave Syer
* @author Mahmoud Ben Hassine
* @since 2.1
*
*/
@@ -136,19 +137,19 @@ public class TaskletParser {
found.append("<" + CHUNK_ELE + "/> element, ");
}
else if (chunkElements.size() > 1) {
found.append(chunkElements.size() + " <" + CHUNK_ELE + "/> elements, ");
found.append(chunkElements.size()).append(" <").append(CHUNK_ELE).append("/> elements, ");
}
if (beanElements.size() == 1) {
found.append("<" + BEAN_ELE + "/> element, ");
}
else if (beanElements.size() > 1) {
found.append(beanElements.size() + " <" + BEAN_ELE + "/> elements, ");
found.append(beanElements.size()).append(" <").append(BEAN_ELE).append("/> elements, ");
}
if (refElements.size() == 1) {
found.append("<" + REF_ELE + "/> element, ");
}
else if (refElements.size() > 1) {
found.append(refElements.size() + " <" + REF_ELE + "/> elements, ");
found.append(refElements.size()).append(" <").append(REF_ELE).append("/> elements, ");
}
found.delete(found.length() - 2, found.length());
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 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.
@@ -173,8 +173,8 @@ public class Neo4jItemReader<T> extends AbstractPaginatedDataItemReader<T> imple
query.append(whereStatement != null ? " WHERE " + whereStatement : "");
query.append(" RETURN ").append(returnStatement);
query.append(" ORDER BY ").append(orderByStatement);
query.append(" SKIP " + (pageSize * page));
query.append(" LIMIT " + pageSize);
query.append(" SKIP ").append(pageSize * page);
query.append(" LIMIT ").append(pageSize);
String resultingQuery = query.toString();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2022 the original author or authors.
* Copyright 2006-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.
@@ -52,7 +52,7 @@ public class SqlPagingQueryUtils {
buildWhereClause(provider, remainingPageQuery, sql);
buildGroupByClause(provider, sql);
sql.append(" ORDER BY ").append(buildSortClause(provider));
sql.append(" " + limitClause);
sql.append(" ").append(limitClause);
return sql.toString();
}
@@ -82,7 +82,7 @@ public class SqlPagingQueryUtils {
sql.append("WHERE ");
buildSortConditions(provider, sql);
sql.append(" ORDER BY ").append(buildSortClause(provider));
sql.append(" " + limitClause);
sql.append(" ").append(limitClause);
return sql.toString();
}
@@ -106,7 +106,7 @@ public class SqlPagingQueryUtils {
sql.append("WHERE ");
buildSortConditions(provider, sql);
sql.append(" ORDER BY ").append(buildSortClause(provider));
sql.append(" " + limitClause);
sql.append(" ").append(limitClause);
return sql.toString();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2007 the original author or authors.
* Copyright 2006-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.
@@ -38,13 +38,13 @@ public class OrderLineAggregator implements LineAggregator<Order> {
public String aggregate(Order order) {
StringBuilder result = new StringBuilder();
result.append(aggregators.get("header").aggregate(order) + LINE_SEPARATOR);
result.append(aggregators.get("customer").aggregate(order) + LINE_SEPARATOR);
result.append(aggregators.get("address").aggregate(order) + LINE_SEPARATOR);
result.append(aggregators.get("billing").aggregate(order) + LINE_SEPARATOR);
result.append(aggregators.get("header").aggregate(order)).append(LINE_SEPARATOR);
result.append(aggregators.get("customer").aggregate(order)).append(LINE_SEPARATOR);
result.append(aggregators.get("address").aggregate(order)).append(LINE_SEPARATOR);
result.append(aggregators.get("billing").aggregate(order)).append(LINE_SEPARATOR);
for (LineItem lineItem : order.getLineItems()) {
result.append(aggregators.get("item").aggregate(lineItem) + LINE_SEPARATOR);
result.append(aggregators.get("item").aggregate(lineItem)).append(LINE_SEPARATOR);
}
result.append(aggregators.get("footer").aggregate(order));

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2008-2022 the original author or authors.
* Copyright 2008-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.
@@ -106,12 +106,12 @@ class CompositeItemWriterSampleFunctionalTests {
private void checkOutputFile(String fileName) throws IOException {
List<String> outputLines = IOUtils.readLines(new FileInputStream(fileName), "UTF-8");
String output = "";
StringBuilder output = new StringBuilder();
for (String line : outputLines) {
output += line;
output.append(line);
}
assertEquals(EXPECTED_OUTPUT_FILE, output);
assertEquals(EXPECTED_OUTPUT_FILE, output.toString());
}
}