Use StringJoiner where possible to simplify String joining
This commit is contained in:
committed by
Juergen Hoeller
parent
f087fd5a93
commit
cb4d6f097c
@@ -19,6 +19,7 @@ package org.springframework.expression.spel.ast;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
import org.springframework.asm.MethodVisitor;
|
||||
import org.springframework.expression.EvaluationException;
|
||||
@@ -102,17 +103,13 @@ public class InlineList extends SpelNodeImpl {
|
||||
|
||||
@Override
|
||||
public String toStringAST() {
|
||||
StringBuilder sb = new StringBuilder("{");
|
||||
StringJoiner sj = new StringJoiner(",", "{", "}");
|
||||
// String ast matches input string, not the 'toString()' of the resultant collection, which would use []
|
||||
int count = getChildCount();
|
||||
for (int c = 0; c < count; c++) {
|
||||
if (c > 0) {
|
||||
sb.append(",");
|
||||
}
|
||||
sb.append(getChild(c).toStringAST());
|
||||
sj.add(getChild(c).toStringAST());
|
||||
}
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
return sj.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user