Skip to content

Commit 8ba1997

Browse files
author
Tanechka
committed
Lesson08 HW07 model implementation
1 parent a1fe80b commit 8ba1997

8 files changed

Lines changed: 283 additions & 2 deletions

File tree

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

‎src/ru/javawebinar/basejava/model/Resume.java‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package ru.javawebinar.basejava.model;
22

3+
import java.util.EnumMap;
4+
import java.util.Map;
35
import java.util.Objects;
46
import java.util.UUID;
57

68
/**
7-
* ru.javawebinar.basejava.model.Resume class
9+
* com.urise.webapp.model.Resume class
810
*/
911
public class Resume implements Comparable<Resume> {
1012

@@ -13,6 +15,9 @@ public class Resume implements Comparable<Resume> {
1315

1416
private final String fullName;
1517

18+
private final Map<ContactType, String> contacts = new EnumMap<>(ContactType.class);
19+
private final Map<SectionType, Section> sections = new EnumMap<>(SectionType.class);
20+
1621
public Resume(String fullName) {
1722
this(UUID.randomUUID().toString(), fullName);
1823
}
@@ -28,6 +33,14 @@ public String getUuid() {
2833
return uuid;
2934
}
3035

36+
public String getContact(ContactType type) {
37+
return contacts.get(type);
38+
}
39+
40+
public Section getSection(SectionType type) {
41+
return sections.get(type);
42+
}
43+
3144
@Override
3245
public boolean equals(Object o) {
3346
if (this == o) return true;
@@ -57,4 +70,4 @@ public int compareTo(Resume o) {
5770
int cmp = fullName.compareTo(o.fullName);
5871
return cmp != 0 ? cmp : uuid.compareTo(o.uuid);
5972
}
60-
}
73+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package ru.javawebinar.basejava.model;
2+
3+
/**
4+
* gkislin
5+
* 19.07.2016
6+
*/
7+
abstract public class Section {
8+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package ru.javawebinar.basejava.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 be 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+
33+
@Override
34+
public int hashCode() {
35+
return content.hashCode();
36+
}
37+
}
38+

0 commit comments

Comments
 (0)