forked from JaeHongDev/java-baseball
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRestartMessage.java
More file actions
28 lines (22 loc) · 834 Bytes
/
RestartMessage.java
File metadata and controls
28 lines (22 loc) · 834 Bytes
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
package baseball;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class RestartMessage {
private static final String RESTART_MESSAGE = "1";
private static final String END_MESSAGE = "2";
private static final Pattern PATTERN = Pattern.compile(String.format("[%s%s]", RESTART_MESSAGE, END_MESSAGE));
private final String value;
public RestartMessage(String value) {
validate(value);
this.value = value;
}
private void validate(String value) {
final Matcher matcher = PATTERN.matcher(value);
if (!matcher.matches()) {
throw new IllegalArgumentException(String.format("[ERROR] 재시작 입력 값은 %s 일 수 없습니다.", value));
}
}
public boolean isEnd() {
return this.value.equals(END_MESSAGE);
}
}