-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDay.java
More file actions
61 lines (45 loc) · 1.29 KB
/
Day.java
File metadata and controls
61 lines (45 loc) · 1.29 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package org.cleancode.journal.domain;
import org.cleancode.journal.util.ToStringUtil;
import java.io.Serializable;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
public class Day implements Comparable<Day>, Serializable {
private final LocalDate date;
private List<LogEntry> logEntries = new ArrayList<>();
public Day(LocalDate date) {
this.date = date;
}
public LocalDate getDate() {
return date;
}
public void addLogEntry(LogEntry logEntry) {
logEntries.add(logEntry);
}
public boolean isEmpty() {
return logEntries.isEmpty();
}
public boolean isSubmitted() {
return !isEmpty();
}
@Override
public int compareTo(Day o) {
return date.compareTo(o.date);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Day day = (Day) o;
return date.equals(day.date) && logEntries.equals(day.logEntries);
}
@Override
public int hashCode() {
return Objects.hash(date, logEntries);
}
@Override
public String toString() {
return ToStringUtil.toString(date) + ":" + logEntries.size();
}
}