1 package cz.cuni.amis.utils.flag;
2
3 import java.io.Serializable;
4
5
6
7
8
9
10
11 public class ImmutableFlag<T> extends Flag<T> implements Serializable {
12
13 protected IFlag<T> flag = null;
14
15
16 public ImmutableFlag(IFlag<T> flag) {
17 this.flag = flag;
18 }
19
20 @Override
21 public void addListener(FlagListener<T> listener) {
22 flag.addListener(listener);
23 }
24
25 @Override
26 public void addStrongListener(FlagListener<T> listener) {
27 flag.addStrongListener(listener);
28 }
29
30 @Override
31 public void clearListeners() {
32 flag.clearListeners();
33 }
34
35 @Override
36 public T getFlag(){
37 return flag.getFlag();
38 }
39
40 @Override
41 public boolean isListenning(FlagListener<T> listener){
42 return flag.isListenning(listener);
43 }
44
45 @Override
46 public void removeListener(FlagListener<T> listener){
47 flag.removeListener(listener);
48 }
49
50 @Override
51 public void setFlag(T newValue) {
52 throw new UnsupportedOperationException("Trying to set value of immutable flag.");
53 }
54
55 @Override
56 public ImmutableFlag<T> getImmutable() {
57 return this;
58 }
59
60 @Override
61 public void inSync(DoInSync<T> command) {
62 flag.inSync(command);
63 }
64
65 @Override
66 public boolean isFrozen() {
67 return flag.isFrozen();
68 }
69
70 @Override
71 public void freeze() {
72 throw new UnsupportedOperationException("Trying to freeze immutable flag.");
73 }
74
75 @Override
76 public void defreeze() {
77 throw new UnsupportedOperationException("Trying to defreeze immutable flag.");
78 }
79
80 }