forked from taywils/java_spark_tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArticleServletDao.java
More file actions
42 lines (33 loc) · 870 Bytes
/
ArticleServletDao.java
File metadata and controls
42 lines (33 loc) · 870 Bytes
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
import java.util.ArrayList;
public class ArticleServletDao<T extends Article> implements ArticleDbService<T> {
ArrayList<T> storage;
public ArticleServletDao() {
storage = new ArrayList<T>();
}
@Override
public Boolean create(T entity) {
storage.add(entity);
return null;
}
@Override
public T readOne(int id) {
return storage.get(id);
}
@Override
public ArrayList<T> readAll() {
return storage;
}
@Override
public Boolean update(int id, String title, String summary, String content) {
T entity = storage.get(id);
entity.setSummary(summary);
entity.setTitle(title);
entity.setContent(content);
return true;
}
@Override
public Boolean delete(int id) {
storage.get(id).delete();
return true;
}
}