forked from JavaOPs/basejava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathResume.java
More file actions
110 lines (86 loc) · 3.1 KB
/
Resume.java
File metadata and controls
110 lines (86 loc) · 3.1 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
package ru.javaops.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.*;
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class Resume implements Comparable<Resume>, Serializable {
private static final long serialVersionUID = 1L;
public static final Resume EMPTY = new Resume();
static {
EMPTY.setSection(SectionType.OBJECTIVE, TextSection.EMPTY);
EMPTY.setSection(SectionType.PERSONAL, TextSection.EMPTY);
EMPTY.setSection(SectionType.ACHIEVEMENT, ListSection.EMPTY);
EMPTY.setSection(SectionType.QUALIFICATIONS, ListSection.EMPTY);
EMPTY.setSection(SectionType.EXPERIENCE, new OrganisationSection(Organisation.EMPTY));
EMPTY.setSection(SectionType.EDUCATION, new OrganisationSection(Organisation.EMPTY));
}
// Unique identifier
private String uuid;
private String fullName;
private final Map<ContactType, String> contacts = new EnumMap<>(ContactType.class);
private final Map<SectionType, Section> sections = new EnumMap<>(SectionType.class);
public Resume() {
}
public Resume(String fullName){
this((UUID.randomUUID().toString()), fullName);
}
public Resume(String uuid, String fullName){
Objects.requireNonNull(uuid, "UUID can't be NULL");
Objects.requireNonNull(fullName, "fullName can't be NULL");
this.uuid = uuid;
this.fullName = fullName;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Resume resume = (Resume) o;
return Objects.equals(uuid, resume.uuid) &&
Objects.equals(fullName, resume.fullName) &&
Objects.equals(contacts, resume.contacts) &&
Objects.equals(sections, resume.sections);
}
@Override
public int hashCode() {
return Objects.hash(uuid, fullName, contacts, sections);
}
@Override
public int compareTo(Resume o) {
int comp = this.fullName.compareTo(o.fullName);
return comp != 0 ? comp : this.uuid.compareTo(o.uuid);
}
public String getUuid() {
return uuid;
}
public String getFullName() {
return fullName;
}
public void setFullName(String fullName){
this.fullName = fullName;
}
public String getContact(ContactType type) {
return contacts.get(type);
}
public Section getSection(SectionType type) {
return sections.get(type);
}
public void setContact(ContactType type, String value) {
this.contacts.put(type, value);
}
public void setSection(SectionType type, Section value) {
this.sections.put(type, value);
}
public Map<ContactType, String> getContacts() {
return contacts;
}
public Map<SectionType, Section> getSections() {
return sections;
}
@Override
public String toString() {
return uuid + " (" + fullName + ")";
}
}