-
Notifications
You must be signed in to change notification settings - Fork 9
/
interfaces.java
44 lines (34 loc) · 929 Bytes
/
interfaces.java
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
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
class AlertService {
private final MapAlertDAO storage = new MapAlertDAO();
public UUID raiseAlert() {
return this.storage.addAlert(new Date());
}
public Date getAlertTime(UUID id) {
return this.storage.getAlert(id);
}
}
class MapAlertDAO implements AlertDAO {
private final Map<UUID, Date> alerts = new HashMap<UUID, Date>();
public UUID addAlert(Date time) {
UUID id = UUID.randomUUID();
this.alerts.put(id, time);
return id;
}
public Date getAlert(UUID id) {
return this.alerts.get(id);
}
}
interface AlertDAO {
public UUID addAlert(Date time) {
UUID id = UUID.randomUUID();
this.alerts.put(id, time);
return id;
}
public Date getAlert(UUID id) {
return this.alerts.get(id);
}
}