]> git.basschouten.com Git - openhab-addons.git/blob
87dd0bff3819f9afb58c338d36fb7166dba4f19d
[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.bticinosmarther.internal.api.dto;
14
15 import org.eclipse.jdt.annotation.Nullable;
16
17 import com.google.gson.annotations.SerializedName;
18
19 /**
20  * The {@code Notification} class defines the dto for Smarther API notification object.
21  *
22  * @author Fabio Possieri - Initial contribution
23  */
24 public class Notification {
25
26     private String id;
27     @SerializedName("eventType")
28     private String eventType;
29     private String subject;
30     @SerializedName("eventTime")
31     private String eventTime;
32     private ModuleStatus data;
33
34     /**
35      * Returns the identifier of this notification.
36      *
37      * @return a string containing the notification identifier
38      */
39     public String getId() {
40         return id;
41     }
42
43     /**
44      * Returns the event type of this notification.
45      *
46      * @return a string containing the notification event type
47      */
48     public String getEventType() {
49         return eventType;
50     }
51
52     /**
53      * Returns the subject of this notification.
54      *
55      * @return a string containing the notification subject
56      */
57     public String getSubject() {
58         return subject;
59     }
60
61     /**
62      * Returns the event time of this notification.
63      *
64      * @return a string containing the notification event time
65      */
66     public String getEventTime() {
67         return eventTime;
68     }
69
70     /**
71      * Returns the module status data (i.e. the payload) of this notification.
72      *
73      * @return the module status data, or {@code null} in case of no data found
74      */
75     public @Nullable ModuleStatus getData() {
76         return data;
77     }
78
79     /**
80      * Returns the chronothermostat details of this notification.
81      *
82      * @return the chronothermostat details, or {@code null} in case of no data found
83      */
84     public @Nullable Chronothermostat getChronothermostat() {
85         if (data != null) {
86             return data.toChronothermostat();
87         }
88         return null;
89     }
90
91     /**
92      * Returns the sender details of this notification.
93      *
94      * @return the sender details, or {@code null} in case of no data found
95      */
96     public @Nullable Sender getSender() {
97         if (data != null) {
98             final Chronothermostat chronothermostat = data.toChronothermostat();
99             if (chronothermostat != null) {
100                 return chronothermostat.getSender();
101             }
102         }
103         return null;
104     }
105
106     @Override
107     public String toString() {
108         return String.format("id=%s, eventType=%s, subject=%s, eventTime=%s, data=[%s]", id, eventType, subject,
109                 eventTime, data);
110     }
111 }