Use StringJoiner where possible to simplify String joining
This commit is contained in:
committed by
Juergen Hoeller
parent
07e9f802f2
commit
383f18e214
@@ -18,6 +18,7 @@ package org.springframework.messaging.handler;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
@@ -51,16 +52,11 @@ public abstract class AbstractMessageCondition<T extends AbstractMessageConditio
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder("[");
|
||||
for (Iterator<?> iterator = getContent().iterator(); iterator.hasNext();) {
|
||||
Object expression = iterator.next();
|
||||
builder.append(expression.toString());
|
||||
if (iterator.hasNext()) {
|
||||
builder.append(getToStringInfix());
|
||||
}
|
||||
StringJoiner joiner = new StringJoiner(getToStringInfix(), "[", "]");
|
||||
for (Object expression : getContent()) {
|
||||
joiner.add(expression.toString());
|
||||
}
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
return joiner.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user