Use StringJoiner where possible to simplify String joining
This commit is contained in:
committed by
Juergen Hoeller
parent
e44d3dabc4
commit
5e29ea30a3
@@ -17,6 +17,7 @@
|
||||
package org.springframework.beans.propertyeditors;
|
||||
|
||||
import java.beans.PropertyEditorSupport;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ClassUtils;
|
||||
@@ -82,14 +83,11 @@ public class ClassArrayEditor extends PropertyEditorSupport {
|
||||
if (ObjectUtils.isEmpty(classes)) {
|
||||
return "";
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < classes.length; ++i) {
|
||||
if (i > 0) {
|
||||
sb.append(",");
|
||||
}
|
||||
sb.append(ClassUtils.getQualifiedName(classes[i]));
|
||||
StringJoiner sj = new StringJoiner(",");
|
||||
for (Class<?> klass : classes) {
|
||||
sj.add(ClassUtils.getQualifiedName(klass));
|
||||
}
|
||||
return sb.toString();
|
||||
return sj.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user