-
Notifications
You must be signed in to change notification settings - Fork 738
Expand file tree
/
Copy pathPlayerName.java
More file actions
38 lines (27 loc) · 921 Bytes
/
PlayerName.java
File metadata and controls
38 lines (27 loc) · 921 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
29
30
31
32
33
34
35
36
37
38
package nextstep.ladder.domain;
import java.util.Objects;
public class PlayerName {
private static final String NAME_OVER_LENGTH_ERROR_TEXT = "사람에 이름을 최대5글자까지 가능합니다.";
private static final int NAME_MAX_LENGTH = 5;
private final String value;
public PlayerName(String value) {
if (value.length() > NAME_MAX_LENGTH) {
throw new IllegalArgumentException(NAME_OVER_LENGTH_ERROR_TEXT);
}
this.value = value;
}
public String getValue() {
return value;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
PlayerName that = (PlayerName) o;
return Objects.equals(value, that.value);
}
@Override
public int hashCode() {
return value != null ? value.hashCode() : 0;
}
}