-
Notifications
You must be signed in to change notification settings - Fork 307
Expand file tree
/
Copy pathPeriod.java
More file actions
39 lines (32 loc) · 1.02 KB
/
Period.java
File metadata and controls
39 lines (32 loc) · 1.02 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
package nextstep.courses.domain;
import java.time.LocalDate;
import java.util.Objects;
public class Period {
private final LocalDate startDate;
private final LocalDate endDate;
public Period(LocalDate startDate, LocalDate endDate) {
if (endDate.isBefore(startDate) || endDate.isEqual(startDate)) {
throw new IllegalArgumentException("종료일은 시작일보다 이후여야 합니다.");
}
this.startDate = startDate;
this.endDate = endDate;
}
public LocalDate getStartDate() {
return startDate;
}
public LocalDate getEndDate() {
return endDate;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Period)) return false;
Period period = (Period) o;
return Objects.equals(startDate, period.startDate) &&
Objects.equals(endDate, period.endDate);
}
@Override
public int hashCode() {
return Objects.hash(startDate, endDate);
}
}