-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathListStorage.java
More file actions
63 lines (50 loc) · 1.26 KB
/
ListStorage.java
File metadata and controls
63 lines (50 loc) · 1.26 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
package webapp.storage;
import webapp.model.Resume;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
public class ListStorage extends AbstractStorage<Integer> {
private ArrayList<Resume> resumeList = new ArrayList<>();
@Override
protected Integer getSearchKey(UUID uuid) {
for (int i = 0; i < resumeList.size(); i++) {
if (resumeList.get(i).getUuid().equals(uuid)) {
return i;
}
}
return -1;
}
@Override
protected boolean isExist(Integer index) {
return index != -1;
}
@Override
protected void doUpdate(Integer SK, Resume r) {
resumeList.set(SK, r);
}
@Override
protected void doSave(Resume r, Integer SK) {
resumeList.add(r);
}
@Override
protected Resume doGet(Integer SK) {
return resumeList.get(SK);
}
@Override
protected void doDelete(Integer SK) {
resumeList.remove((int) SK);
resumeList.trimToSize();
}
@Override
public void clear() {
resumeList.clear();
}
@Override
public List<Resume> doGetAll() {
return new ArrayList<>(resumeList);
}
@Override
public int size() {
return resumeList.size();
}
}