-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathValidatorV1Main.java
More file actions
44 lines (37 loc) · 1.23 KB
/
Copy pathValidatorV1Main.java
File metadata and controls
44 lines (37 loc) · 1.23 KB
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
39
40
41
42
43
44
package annotation.validator;
import util.MyLogger;
import static util.MyLogger.log;
public class ValidatorV1Main {
public static void main(String[] args) {
User user = new User("user1", 0);
Team team = new Team("", 0);
try{
log("== user 검증 ==");
validateUser(user);
} catch (Exception e){
log(e);
}
try{
log("== team 검증 ==");
validateTeam(team);
} catch (Exception e){
log(e);
}
}
private static void validateTeam(Team team) {
if(team.getName() == null || team.getName().isEmpty()){
throw new RuntimeException("이름이 비었습니다.");
}
if(team.getMemberCount() < 1 || team.getMemberCount() > 999){
throw new RuntimeException("회원 수는 1과 999사이 여야합니다.");
}
}
private static void validateUser(User user) {
if(user.getName() == null || user.getName().isEmpty()) {
throw new RuntimeException("이름이 비었습니다.");
}
if(user.getAge() < 1 || user.getAge() > 100) {
throw new RuntimeException("나이는 1과 100사이 여야합니다.");
}
}
}