1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.fourthline.cling.support.renderingcontrol.lastchange;
17
18 import org.fourthline.cling.model.types.BooleanDatatype;
19 import org.fourthline.cling.model.types.Datatype;
20 import org.fourthline.cling.model.types.InvalidValueException;
21 import org.fourthline.cling.support.lastchange.EventedValue;
22 import org.fourthline.cling.support.model.Channel;
23 import org.fourthline.cling.support.shared.AbstractMap;
24
25 import java.util.Map;
26
27
28
29
30 public class EventedValueChannelMute extends EventedValue<ChannelMute> {
31
32 public EventedValueChannelMute(ChannelMute value) {
33 super(value);
34 }
35
36 public EventedValueChannelMute(Map.Entry<String, String>[] attributes) {
37 super(attributes);
38 }
39
40 @Override
41 protected ChannelMute valueOf(Map.Entry<String, String>[] attributes) throws InvalidValueException {
42 Channel channel = null;
43 Boolean mute = null;
44 for (Map.Entry<String, String> attribute : attributes) {
45 if (attribute.getKey().equals("channel"))
46 channel = Channel.valueOf(attribute.getValue());
47 if (attribute.getKey().equals("val"))
48 mute = new BooleanDatatype().valueOf(attribute.getValue());
49 }
50 return channel != null && mute != null ? new ChannelMute(channel, mute) : null;
51 }
52
53 @Override
54 public Map.Entry<String, String>[] getAttributes() {
55 return new Map.Entry[]{
56 new AbstractMap.SimpleEntry<>(
57 "val",
58 new BooleanDatatype().getString(getValue().getMute())
59 ),
60 new AbstractMap.SimpleEntry<>(
61 "channel",
62 getValue().getChannel().name()
63 )
64 };
65 }
66
67 @Override
68 public String toString() {
69 return getValue().toString();
70 }
71
72 @Override
73 protected Datatype getDatatype() {
74 return null;
75 }
76 }