blob: 0ac26ccc714bbec98d6386f60250702027efa89b (
plain)
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
|
package net.lacolaco.smileessence.entity;
import java.util.*;
public class SavedSearch implements IdObject {
private static Map<Long, SavedSearch> storage = new HashMap<>();
public synchronized static Collection<SavedSearch> cached() {
return storage.values();
}
public synchronized static void replace(List<SavedSearch> list) {
storage = new HashMap<>();
for (SavedSearch ss : list)
storage.put(ss.getId(), ss);
}
public synchronized static SavedSearch fromTwitter(twitter4j.SavedSearch obj) {
SavedSearch cached = storage.get(obj.getId());
/* SavedSearch should be immutable */
if (cached == null) {
cached = new SavedSearch(obj.getId(), obj.getQuery());
}
return cached;
}
// インスタンス
private long id;
private String query;
private SavedSearch(long id, String query) {
this.id = id;
this.query = query;
}
public long getId() {
return id;
}
public String getQuery() {
return query;
}
}
|