]> git.basschouten.com Git - openhab-addons.git/blob
f7bfc7bbf98ec31fdd3a92d5370a060339043cef
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
7  * This program and the accompanying materials are made available under the
8  * terms of the Eclipse Public License 2.0 which is available at
9  * http://www.eclipse.org/legal/epl-2.0
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.tellstick.internal.live.xml;
14
15 import javax.xml.bind.annotation.XmlAccessType;
16 import javax.xml.bind.annotation.XmlAccessorType;
17 import javax.xml.bind.annotation.XmlAttribute;
18 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
19
20 import org.tellstick.device.iface.Device;
21 import org.tellstick.enums.DeviceType;
22
23 /**
24  * Class used to deserialize XML from Telldus Live.
25  *
26  * @author Jarle Hjortland - Initial contribution
27  */
28 @XmlAccessorType(XmlAccessType.FIELD)
29 public class TellstickNetDevice implements Device {
30     @XmlAttribute(name = "id")
31     int deviceId;
32     private String protocol;
33     private String model;
34     @XmlAttribute()
35     private String name;
36     @XmlAttribute()
37     @XmlJavaTypeAdapter(value = NumberToBooleanMapper.class)
38     private Boolean online;
39     @XmlAttribute
40     private int state;
41     @XmlAttribute
42     private String statevalue;
43     @XmlAttribute
44     private int methods;
45
46     private boolean updated;
47
48     public TellstickNetDevice() {
49     }
50
51     public TellstickNetDevice(int id) {
52         this.deviceId = id;
53     }
54
55     @Override
56     public int getId() {
57         return deviceId;
58     }
59
60     @Override
61     public String getUUId() {
62         return Integer.toString(deviceId);
63     }
64
65     @Override
66     public String getProtocol() {
67         return protocol;
68     }
69
70     @Override
71     public String getModel() {
72         return model;
73     }
74
75     @Override
76     public DeviceType getDeviceType() {
77         return DeviceType.DEVICE;
78     }
79
80     @Override
81     public String getName() {
82         return name;
83     }
84
85     public void setId(int deviceId) {
86         this.deviceId = deviceId;
87     }
88
89     public void setProtocol(String protocol) {
90         this.protocol = protocol;
91     }
92
93     public void setModel(String model) {
94         this.model = model;
95     }
96
97     public void setName(String name) {
98         this.name = name;
99     }
100
101     public boolean getOnline() {
102         return online;
103     }
104
105     // @XmlJavaTypeAdapter(value = NumberToBooleanMapper.class)
106     public void setOnline(boolean online) {
107         this.online = online;
108     }
109
110     public void setUpdated(boolean b) {
111         this.updated = b;
112     }
113
114     public boolean isUpdated() {
115         return updated;
116     }
117
118     public int getState() {
119         return state;
120     }
121
122     public void setState(int state) {
123         this.state = state;
124     }
125
126     public String getStatevalue() {
127         return statevalue;
128     }
129
130     public void setStatevalue(String statevalue) {
131         this.statevalue = statevalue;
132     }
133
134     @Override
135     public int hashCode() {
136         int prime = 31;
137         int result = 1;
138         result = prime * result + deviceId;
139         return result;
140     }
141
142     @Override
143     public boolean equals(Object obj) {
144         if (this == obj) {
145             return true;
146         }
147         if (obj == null) {
148             return false;
149         }
150         if (getClass() != obj.getClass()) {
151             return false;
152         }
153         TellstickNetDevice other = (TellstickNetDevice) obj;
154         return deviceId == other.deviceId;
155     }
156
157     public int getMethods() {
158         return methods;
159     }
160
161     public void setMethods(int methods) {
162         this.methods = methods;
163     }
164
165     @Override
166     public String toString() {
167         return "TellstickNetDevice [deviceId=" + deviceId + ", name=" + name + ", online=" + online + ", state=" + state
168                 + ", statevalue=" + statevalue + ", updated=" + updated + "]";
169     }
170 }