Skip to content

Commit 5f0ce9a

Browse files
committed
lesson 7.
1 parent 13e623a commit 5f0ce9a

File tree

9 files changed

+274
-2
lines changed

9 files changed

+274
-2
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.urise.webapp.model;
2+
3+
public enum ContactType {
4+
PHONE("Тел."),
5+
MOBILE("Мобильный"),
6+
НОMЕ_PHONE("Домашний тел."),
7+
SKYPE("Skype"),
8+
MAIL("Почта"),
9+
LINKEDIN("Профиль LinkedIn"),
10+
GITHUB("Профиль GitHub"),
11+
STATCKOVERFLOW("Профиль Stackoverflow"),
12+
НОMЕ_PAGE("Домашняя страница");
13+
14+
private final String title;
15+
16+
ContactType(String title) {
17+
this.title = title;
18+
}
19+
20+
public String getTitle() {
21+
return title;
22+
}
23+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package com.urise.webapp.model;
2+
3+
import java.util.Objects;
4+
5+
public class Link {
6+
private final String name;
7+
private final String url;
8+
9+
public Link(String name, String url) {
10+
Objects.requireNonNull(name,"name must not be null");
11+
this.name = name;
12+
this.url = url;
13+
}
14+
15+
public String getName() {
16+
return name;
17+
}
18+
19+
public String getUrl() {
20+
return url;
21+
}
22+
23+
@Override
24+
public String toString() {
25+
return "Link ("+ name + ',' + url + ')';
26+
}
27+
28+
@Override
29+
public boolean equals(Object o) {
30+
if (this == o) return true;
31+
if (o == null || getClass() != o.getClass()) return false;
32+
33+
Link link = (Link) o;
34+
35+
if (!name.equals(link.name)) return false;
36+
return url != null ? url.equals(link.url) : link.url == null;
37+
}
38+
39+
@Override
40+
public int hashCode() {
41+
int result = name.hashCode();
42+
result = 31 * result + (url != null ? url.hashCode() : 0);
43+
return result;
44+
}
45+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.urise.webapp.model;
2+
3+
import java.util.List;
4+
import java.util.Objects;
5+
6+
public class ListSection extends Section {
7+
private final List<String> items;
8+
9+
public ListSection(List<String> items) {
10+
Objects.requireNonNull(items,"items must not null");
11+
this.items = items;
12+
}
13+
14+
public List<String> getItems() {
15+
return items;
16+
}
17+
18+
@Override
19+
public String toString() {
20+
return items.toString();
21+
}
22+
23+
@Override
24+
public boolean equals(Object o) {
25+
if (this == o) return true;
26+
if (o == null || getClass() != o.getClass()) return false;
27+
28+
ListSection that = (ListSection) o;
29+
30+
return items.equals(that.items);
31+
}
32+
33+
@Override
34+
public int hashCode() {
35+
return items.hashCode();
36+
}
37+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package com.urise.webapp.model;
2+
3+
import java.io.ObjectInput;
4+
import java.time.LocalDate;
5+
import java.util.Objects;
6+
7+
public class Organization {
8+
private final Link homePage;
9+
private final LocalDate startDate;
10+
private final LocalDate endDate;
11+
private final String title;
12+
private final String description;
13+
14+
public Organization(String name, String url, LocalDate startDate, LocalDate endDate, String title, String description) {
15+
Objects.requireNonNull(startDate,"startDate must not null");
16+
Objects.requireNonNull(endDate,"endDate must not null");
17+
Objects.requireNonNull(title,"title must not null");
18+
19+
this.homePage = new Link(name,url);
20+
this.startDate = startDate;
21+
this.endDate = endDate;
22+
this.title = title;
23+
this.description = description;
24+
}
25+
26+
@Override
27+
public String toString() {
28+
return "Organization{" +
29+
"homePage=" + homePage +
30+
", startDate=" + startDate +
31+
", endDate=" + endDate +
32+
", title='" + title + '\'' +
33+
", description='" + description + '\'' +
34+
'}';
35+
}
36+
37+
@Override
38+
public boolean equals(Object o) {
39+
if (this == o) return true;
40+
if (o == null || getClass() != o.getClass()) return false;
41+
42+
Organization that = (Organization) o;
43+
44+
if (!homePage.equals(that.homePage)) return false;
45+
if (!startDate.equals(that.startDate)) return false;
46+
if (!endDate.equals(that.endDate)) return false;
47+
if (!title.equals(that.title)) return false;
48+
return description != null ? description.equals(that.description) : that.description == null;
49+
}
50+
51+
@Override
52+
public int hashCode() {
53+
int result = homePage.hashCode();
54+
result = 31 * result + startDate.hashCode();
55+
result = 31 * result + endDate.hashCode();
56+
result = 31 * result + title.hashCode();
57+
result = 31 * result + (description != null ? description.hashCode() : 0);
58+
return result;
59+
}
60+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.urise.webapp.model;
2+
3+
import java.util.List;
4+
import java.util.Objects;
5+
6+
public class OrganizationSection extends Section {
7+
private final List<Organization> organizations;
8+
9+
public OrganizationSection(List<Organization> organizations) {
10+
Objects.requireNonNull(organizations,"organizations must not null");
11+
this.organizations = organizations;
12+
}
13+
14+
public List<Organization> getOrganizations() {
15+
return organizations;
16+
}
17+
18+
@Override
19+
public String toString() {
20+
return organizations.toString();
21+
}
22+
23+
@Override
24+
public boolean equals(Object o) {
25+
if (this == o) return true;
26+
if (o == null || getClass() != o.getClass()) return false;
27+
28+
OrganizationSection that = (OrganizationSection) o;
29+
30+
return organizations.equals(that.organizations);
31+
}
32+
33+
@Override
34+
public int hashCode() {
35+
return organizations.hashCode();
36+
}
37+
}

src/com/urise/webapp/model/Resume.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.urise.webapp.model;
22

3-
import java.util.Objects;
4-
import java.util.UUID;
3+
import java.util.*;
54

65
/**
76
* Initial resume class
@@ -12,6 +11,10 @@ public class Resume {
1211
private final String uuid;
1312
private final String fullName;
1413

14+
private final Map<ContactType, String> contacs = new EnumMap<>(ContactType.class);
15+
private final Map<SectionType, Section> sections = new EnumMap<>(SectionType.class);
16+
17+
1518
public Resume(String fullName) {
1619
this(UUID.randomUUID().toString(), fullName);
1720
}
@@ -23,6 +26,13 @@ public Resume(String uuid, String fullName) {
2326
this.fullName = fullName;
2427
}
2528

29+
public String getContact (ContactType type){
30+
return contacs.get(type);
31+
}
32+
public Section getSection (SectionType type){
33+
return sections.get(type);
34+
}
35+
2636
public String getUuid() {
2737
return uuid;
2838
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package com.urise.webapp.model;
2+
3+
public abstract class Section {
4+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.urise.webapp.model;
2+
3+
public enum SectionType {
4+
PERSONAL ("Личные качества"),
5+
OBJECTIVE ("Позиция"),
6+
ACHIEVEMENT ("Достижения"),
7+
QUALIFICATIONS ("Квалификация"),
8+
EXPIRIENCE ("Опыт работы"),
9+
EDUCATION ("Образование");
10+
11+
private String title;
12+
13+
SectionType(String title) {
14+
this.title = title;
15+
}
16+
17+
public String getTitle() {
18+
return title;
19+
}
20+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.urise.webapp.model;
2+
3+
import java.util.Objects;
4+
5+
public class TextSection extends Section {
6+
private final String content;
7+
8+
public TextSection(String content) {
9+
Objects.requireNonNull(content,"content must not null");
10+
this.content = content;
11+
}
12+
13+
public String getContent() {
14+
return content;
15+
}
16+
17+
@Override
18+
public String toString() {
19+
return content;
20+
}
21+
22+
@Override
23+
public boolean equals(Object o) {
24+
if (this == o) return true;
25+
if (o == null || getClass() != o.getClass()) return false;
26+
27+
TextSection that = (TextSection) o;
28+
29+
return content.equals(that.content);
30+
}
31+
32+
@Override
33+
public int hashCode() {
34+
return content.hashCode();
35+
}
36+
}

0 commit comments

Comments
 (0)