]> git.basschouten.com Git - openhab-addons.git/blob
ef3e87d8e4aafe8d788e22595ea35502da1ac30b
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 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.livisismarthome.internal.client.api.entity.message;
14
15 import java.util.List;
16
17 import com.google.gson.annotations.SerializedName;
18
19 /**
20  * Defines the structure of a {@link MessageDTO}. Messages are part of the LIVISI SmartHome system and besides other
21  * things
22  * are used
23  * to raise battery warnings.
24  *
25  * @author Oliver Kuhl - Initial contribution
26  */
27 public class MessageDTO {
28
29     /** device related messages */
30     public static final String TYPE_DEVICE_UNREACHABLE = "DeviceUnreachable";
31     public static final String TYPE_DEVICE_LOW_BATTERY = "DeviceLowBattery";
32
33     /**
34      * Identifier of the message – must be unique.
35      */
36     private String id;
37
38     /**
39      * Specifies the type of the message.
40      */
41     private String type;
42
43     /**
44      * Defines whether the message has been viewed by a user.
45      */
46     @SerializedName("read")
47     private boolean isRead;
48
49     /**
50      * Defines whether it is an alert or a message, default is message.
51      */
52     @SerializedName("class")
53     private String messageClass;
54
55     /**
56      * Timestamp when the message was created.
57      *
58      * Optional.
59      */
60     private String timestamp;
61
62     /**
63      * Reference to the underlying devices, which the message relates to.
64      *
65      * Optional.
66      */
67     private List<String> devices;
68
69     /**
70      * Container for all parameters of the message. The parameters are contained in Property entities.
71      *
72      * Optional.
73      */
74     private MessagePropertiesDTO properties;
75
76     /**
77      * The product (context) that generated the message.
78      */
79     private String namespace;
80
81     /**
82      * @return the id
83      */
84     public String getId() {
85         return id;
86     }
87
88     /**
89      * @param id the id to set
90      */
91     public void setId(String id) {
92         this.id = id;
93     }
94
95     /**
96      * @return the type
97      */
98     public String getType() {
99         return type;
100     }
101
102     /**
103      * @param type the type to set
104      */
105     public void setType(String type) {
106         this.type = type;
107     }
108
109     /**
110      * @return the messageClass
111      */
112     public String getMessageClass() {
113         return messageClass;
114     }
115
116     /**
117      * @param messageClass the messageClass to set
118      */
119     public void setMessageClass(String messageClass) {
120         this.messageClass = messageClass;
121     }
122
123     /**
124      * @return the timestamp
125      */
126     public String getTimestamp() {
127         return timestamp;
128     }
129
130     /**
131      * @param timestamp the timestamp to set
132      */
133     public void setTimestamp(String timestamp) {
134         this.timestamp = timestamp;
135     }
136
137     /**
138      * @return the isRead
139      */
140     public boolean isRead() {
141         return isRead;
142     }
143
144     /**
145      * @param isRead the isRead to set
146      */
147     public void setRead(boolean isRead) {
148         this.isRead = isRead;
149     }
150
151     /**
152      * @return the devices
153      */
154     public List<String> getDevices() {
155         return devices;
156     }
157
158     /**
159      * @param devices the devices to set
160      */
161     public void setDevices(List<String> devices) {
162         this.devices = devices;
163     }
164
165     /**
166      * @return the dataPropertyList
167      */
168     public MessagePropertiesDTO getProperties() {
169         return properties;
170     }
171
172     /**
173      * @param properties the dataPropertyList to set
174      */
175     public void setProperties(MessagePropertiesDTO properties) {
176         this.properties = properties;
177     }
178
179     /**
180      * @return the namespace
181      */
182     public String getNamespace() {
183         return namespace;
184     }
185
186     /**
187      * @param namespace the namespace to set
188      */
189     public void setNamespace(String namespace) {
190         this.namespace = namespace;
191     }
192
193     /**
194      * Returns true, if the message is of type "DeviceUnreachable".
195      *
196      * @return true if the message is of type "DeviceUnreachable", otherwise false
197      */
198     public boolean isTypeDeviceUnreachable() {
199         return TYPE_DEVICE_UNREACHABLE.equals(type);
200     }
201
202     /**
203      * Returns true, if the message is of type "DeviceLowBattery".
204      *
205      * @return true if the message is of type "DeviceLowBattery", otherwise false
206      */
207     public boolean isTypeDeviceLowBattery() {
208         return TYPE_DEVICE_LOW_BATTERY.equals(type);
209     }
210 }