-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainCollection.java
More file actions
61 lines (50 loc) · 1.88 KB
/
MainCollection.java
File metadata and controls
61 lines (50 loc) · 1.88 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
import com.dofler.webapp.model.Resume;
import java.util.*;
public class MainCollection {
private static final String UUID_1;
private static final String UUID_2;
private static final String UUID_3;
private static final Resume RESUME_1;
private static final Resume RESUME_2;
private static final Resume RESUME_3;
// Используется для проверки checked-исключений при создании объекта
static {
UUID_1 = "uuid1";
UUID_2 = "uuid2";
UUID_3 = "uuid3";
RESUME_1 = new Resume(UUID_1);
RESUME_2 = new Resume(UUID_2);
RESUME_3 = new Resume(UUID_3);
}
public static void main(String[] args) {
Collection<Resume> resumesCollection = new ArrayList<>();
resumesCollection.add(RESUME_1);
resumesCollection.add(RESUME_2);
resumesCollection.add(RESUME_3);
for (Resume r : resumesCollection) {
System.out.println(r);
if (Objects.equals(r.getUuid(), UUID_1)) {
//resumesCollection.remove(r);
}
}
Iterator<Resume> iteratorResume = resumesCollection.iterator();
while (iteratorResume.hasNext()) {
Resume r = iteratorResume.next();
System.out.println(r);
if (Objects.equals(r.getUuid(), UUID_1)) {
iteratorResume.remove();
}
}
System.out.println(resumesCollection.toString());
Map<String, Resume> mapResume = new HashMap<>();
mapResume.put(UUID_1, RESUME_1);
mapResume.put(UUID_2, RESUME_2);
mapResume.put(UUID_3, RESUME_3);
for (String uuid : mapResume.keySet()) {
System.out.println(mapResume.get(uuid));
}
for (Map.Entry<String, Resume> entry : mapResume.entrySet()) {
System.out.println(entry.getValue());
}
}
}