-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathResume.java
More file actions
139 lines (115 loc) · 4.38 KB
/
Resume.java
File metadata and controls
139 lines (115 loc) · 4.38 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
package webapp.model;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
import java.util.EnumMap;
import java.util.Map;
import java.util.Objects;
import java.util.UUID;
import static webapp.model.Section.EMPTY_STRING;
import static webapp.model.TypeOfContact.*;
import static webapp.model.TypeOfSection.*;
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class Resume implements Comparable<Resume>, Serializable {
private static final long serialVersionUID = 1L;
/**
* Resume = structure of
* uuid UUID
* fullName string
* contacts EnumMap < TypeOfContact, String>
* sections EnumMap < TypeOfSection, Section>
*/
public static final Resume EMPTY = new Resume();
static {
// EMPTY.setContact(TypeOfContact.EMPTY, EMPTY_STRING);
EMPTY.setSection(OBJECTIVE, StringSection.EMPTY);
EMPTY.setSection(TypeOfSection.PERSONAL, StringSection.EMPTY);
EMPTY.setSection(TypeOfSection.ACHIEVEMENT, ListSection.EMPTY);
EMPTY.setSection(QUALIFICATIONS, ListSection.EMPTY);
EMPTY.setSection(TypeOfSection.EXPERIENCE, OrganizationSection.EMPTY);
EMPTY.setSection(TypeOfSection.EDUCATION, OrganizationSection.EMPTY);
}
public UUID uuid;
private String fullName;
private Map<TypeOfContact, String> contacts = new EnumMap<>(TypeOfContact.class);
private Map<TypeOfSection, Section> sections = new EnumMap<>(TypeOfSection.class);
public Resume() {
// this.uuid = UUID.randomUUID();
// this.fullName = EMPTY_STRING;
}
public Resume(String fullName) {
this(UUID.randomUUID(), fullName);
}
public Resume(UUID uuid, String fullName) {
Objects.requireNonNull(uuid, "uuid must not be null");
Objects.requireNonNull(fullName, "fullName must not be null");
this.fullName = fullName;
this.uuid = uuid;
}
// Resume getters
public UUID getUuid() {
return uuid;
}
public String getFullName() {
return fullName;
}
public Map<TypeOfContact, String> getContacts() {
return contacts;
}
public Map<TypeOfSection, Section> getSections() {
return sections;
}
public String getContact(TypeOfContact type) {
return contacts.get(type);
}
public Section getSection(TypeOfSection type) {
return sections.get(type);
}
// Resume setters
public void setFullName(String fullName) {
this.fullName = fullName;
}
public void setContact(TypeOfContact type, String value) {
contacts.put(type, value);
}
public void setSection(TypeOfSection type, Section section) {
sections.put(type, section);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Resume)) return false;
Resume resume = (Resume) o;
return Objects.equals(getUuid(), resume.getUuid()) &&
Objects.equals(getFullName(), resume.getFullName()) &&
Objects.equals(getContacts(), resume.getContacts()) &&
Objects.equals(getSections(), resume.getSections());
}
@Override
public int hashCode() {
return Objects.hash(getUuid(), getFullName(), getContacts(), getSections());
}
@Override
public int compareTo(Resume o) {
int cmp = fullName.compareTo(o.fullName);
return cmp != 0 ? cmp : uuid.compareTo(o.uuid);
}
@Override
public String toString() {
return "Resume [" + "\n" +
"uuid=" + uuid + "\n" +
"fullName=" + fullName + "\n" +
"contacts.HOMEPHONE=" + getContact(HOMEPHONE) + "\n" +
"contacts.MOBILEPHONE=" + getContact(MOBILEPHONE) + "\n" +
"contacts.SKYPE=" + getContact(SKYPE) + "\n" +
"sections.OBJECTIVE=" + getSection(OBJECTIVE) + "\n" +
"sections.PERSONAL=" + getSection(PERSONAL) + "\n" +
"sections.ACHIEVEMENT=" + getSection(ACHIEVEMENT) + "\n" +
"sections.QUALIFICATIONS=" + getSection(QUALIFICATIONS) + "\n" +
"sections.EXPERIENCE=" + getSection(EXPERIENCE) + "\n" +
"sections.EDUCATION=" + getSection(EDUCATION) + "\n" +
']';
}
}