Better implementation of

org.apache.commons.lang3.builder.MultilineRecursiveToStringStyle.spacer(int)
This commit is contained in:
Gary Gregory 2024-05-12 18:13:45 -04:00
parent 5e36226a06
commit 74a9bea58f
1 changed files with 3 additions and 6 deletions

View File

@ -18,6 +18,7 @@
package org.apache.commons.lang3.builder;
import org.apache.commons.lang3.ClassUtils;
import org.apache.commons.lang3.StringUtils;
/**
* Works with {@link ToStringBuilder} to create a "deep" {@code toString}.
@ -206,12 +207,8 @@ public class MultilineRecursiveToStringStyle extends RecursiveToStringStyle {
* @param spaces how far to indent
* @return a StringBuilder with {spaces} leading space characters.
*/
private StringBuilder spacer(final int spaces) {
final StringBuilder sb = new StringBuilder();
for (int i = 0; i < spaces; i++) {
sb.append(" ");
}
return sb;
private String spacer(final int spaces) {
return StringUtils.repeat(' ', spaces);
}
}