-
Notifications
You must be signed in to change notification settings - Fork 712
/
Copy pathDecoratingUtils.java
32 lines (26 loc) · 1 KB
/
DecoratingUtils.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package ladderapplication.utils;
public class DecoratingUtils {
private static final String EMPTY = " ";
private static final String STEP_PIECE = "-";
private static final int NAME_SPACE = 6;
private static final int STANDARD_SIZE = 4;
private static final int STEP_LENGTH = 5;
public static String getDecoratedName(String name) {
StringBuilder sb = new StringBuilder();
if (name.length() < STANDARD_SIZE) {
sb.append(getRepeatCharacter(EMPTY, STANDARD_SIZE - name.length()));
}
sb.append(name)
.append(getRepeatCharacter(EMPTY, NAME_SPACE - sb.length()));
return sb.toString();
}
private static String getRepeatCharacter(String character, int repeatCount) {
return character.repeat(repeatCount);
}
public static String getStep(boolean hasStep) {
if (hasStep) {
return getRepeatCharacter(STEP_PIECE, STEP_LENGTH);
}
return getRepeatCharacter(EMPTY, STEP_LENGTH);
}
}