-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathChannel.java
More file actions
42 lines (36 loc) · 859 Bytes
/
Channel.java
File metadata and controls
42 lines (36 loc) · 859 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
package observer2;
import java.util.ArrayList;
import java.util.List;
public class Channel implements Subject {
String title;
private List<Subscriber> subs = new ArrayList<>();
/* (non-Javadoc)
* @see observer2.Subject#subscribe(observer2.Subscriber)
*/
@Override
public void subscribe(Subscriber subscriber) {
subs.add(subscriber);
}
/* (non-Javadoc)
* @see observer2.Subject#unsubscribe(observer2.Oberver)
*/
@Override
public void unsubscribe(Oberver subscriber) {
subs.remove(subscriber);
}
/* (non-Javadoc)
* @see observer2.Subject#notifySubscribers()
*/
@Override
public void notifySubscribers() {
subs.stream().forEach(s -> s.update());
}
/* (non-Javadoc)
* @see observer2.Subject#upload(java.lang.String)
*/
@Override
public void upload(String title) {
this.title = title;
notifySubscribers();
}
}