Skip to content

Commit 504354f

Browse files
authored
Simplify appending with separators (#322)
1 parent 062d0fa commit 504354f

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

dumper/app/src/main/java/com/google/edwmigration/dumper/application/dumper/connector/teradata/query/ExpressionSerializer.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -209,22 +209,26 @@ private void append(Optional<String> aliasMaybe) {
209209
}
210210

211211
private <T> void appendCommaSeparated(ImmutableList<T> list, Consumer<T> appender) {
212-
appendWithSeparators(list, ",", appender);
212+
internalAppendWithSeparators(list, ", ", appender);
213213
}
214214

215215
private <T> void appendWithSeparators(
216216
ImmutableList<T> list, String separator, Consumer<T> appender) {
217+
internalAppendWithSeparators(list, " " + separator + " ", appender);
218+
}
219+
220+
private <T> void internalAppendWithSeparators(
221+
ImmutableList<T> list, String separator, Consumer<T> appender) {
217222
boolean first = true;
223+
if (!list.isEmpty()) {
224+
serializedQuery.append(' ');
225+
}
218226
for (T element : list) {
219227
if (first) {
220228
first = false;
221229
} else {
222-
if (!separator.equals(",")) {
223-
serializedQuery.append(' ');
224-
}
225230
serializedQuery.append(separator);
226231
}
227-
serializedQuery.append(' ');
228232
appender.accept(element);
229233
}
230234
}

0 commit comments

Comments
 (0)