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; package org.apache.commons.lang3.builder;
import org.apache.commons.lang3.ClassUtils; import org.apache.commons.lang3.ClassUtils;
import org.apache.commons.lang3.StringUtils;
/** /**
* Works with {@link ToStringBuilder} to create a "deep" {@code toString}. * 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 * @param spaces how far to indent
* @return a StringBuilder with {spaces} leading space characters. * @return a StringBuilder with {spaces} leading space characters.
*/ */
private StringBuilder spacer(final int spaces) { private String spacer(final int spaces) {
final StringBuilder sb = new StringBuilder(); return StringUtils.repeat(' ', spaces);
for (int i = 0; i < spaces; i++) {
sb.append(" ");
}
return sb;
} }
} }