-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPosition.java
More file actions
86 lines (71 loc) · 2.62 KB
/
Position.java
File metadata and controls
86 lines (71 loc) · 2.62 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package webapp.model;
import webapp.util.LocalDateAdapter;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import java.io.Serializable;
import java.time.LocalDate;
import java.util.Objects;
import static webapp.model.Section.EMPTY_DATE;
import static webapp.model.Section.EMPTY_STRING;
@XmlAccessorType(XmlAccessType.FIELD)
public class Position implements Serializable {
// Data structure
@XmlJavaTypeAdapter(LocalDateAdapter.class)
private LocalDate startDate;
@XmlJavaTypeAdapter(LocalDateAdapter.class)
private LocalDate endDate;
private String positionName;
private String description;
public static final Position EMPTY = new Position();
// public Position() {
// this(EMPTY_DATE, EMPTY_DATE, EMPTY_STRING, EMPTY_STRING);
// }
public Position() {
}
public Position(LocalDate startDate, LocalDate endDate, String positionName, String description) {
Objects.requireNonNull(startDate, "startDate must not be null");
Objects.requireNonNull(endDate, "endDate must not be null");
Objects.requireNonNull(positionName, "title must not be null");
this.startDate = startDate;
this.endDate = endDate;
this.positionName = positionName;
this.description = description == null ? EMPTY_STRING : description;
}
// Getters
public LocalDate getStartDate() {
return startDate;
}
public LocalDate getEndDate() {
return endDate;
}
public String getPositionName() {
return positionName;
}
public String getDescription() {
return description;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Position)) return false;
Position position = (Position) o;
return Objects.equals(getStartDate(), position.getStartDate()) &&
Objects.equals(getEndDate(), position.getEndDate()) &&
Objects.equals(getPositionName(), position.getPositionName()) &&
Objects.equals(getDescription(), position.getDescription());
}
@Override
public int hashCode() {
return Objects.hash(getStartDate(), getEndDate(), getPositionName(), getDescription());
}
@Override
public String toString() {
return "Position{" +
"startDate=" + startDate +
", endDate=" + endDate +
", positionName='" + positionName + '\'' +
", description='" + description + '\'' +
'}';
}
}