2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.livisismarthome.internal.client.api.entity.event;
15 import java.util.Collections;
17 import java.util.stream.Collectors;
18 import java.util.stream.Stream;
21 * @author Oliver Kuhl - Initial contribution
23 public class BaseEventDTO {
25 public static final String TYPE_STATE_CHANGED = "StateChanged";// "device/SHC.RWE/1.0/event/StateChanged";
26 public static final String TYPE_NEW_MESSAGE_RECEIVED = "NewMessageReceived"; // "device/SHC.RWE/1.0/event/NewMessageReceived";
27 public static final String TYPE_MESSAGE_CREATED = "MessageCreated";
28 public static final String TYPE_MESSAGE_DELETED = "MessageDeleted"; // "device/SHC.RWE/1.0/event/MessageDeleted";
29 public static final String TYPE_DISCONNECT = "Disconnect"; // "/event/Disconnect";
30 public static final String TYPE_CONFIGURATION_CHANGED = "ConfigurationChanged"; // "device/SHC.RWE/1.0/event/ConfigChanged";
31 public static final String TYPE_CONTROLLER_CONNECTIVITY_CHANGED = "/event/ControllerConnectivityChanged"; // "device/SHC.RWE/1.0/event/ControllerConnectivityChanged";
32 public static final String TYPE_BUTTON_PRESSED = "ButtonPressed";
34 public static final Set<String> SUPPORTED_EVENT_TYPES = Collections
35 .unmodifiableSet(Stream.of(TYPE_STATE_CHANGED, TYPE_NEW_MESSAGE_RECEIVED, TYPE_MESSAGE_CREATED,
36 TYPE_MESSAGE_DELETED, TYPE_DISCONNECT, TYPE_CONFIGURATION_CHANGED,
37 TYPE_CONTROLLER_CONNECTIVITY_CHANGED, TYPE_BUTTON_PRESSED).collect(Collectors.toSet()));
40 * The event sequence number – the gateway keeps track and adds a sequence number to each event for the client to
41 * identify order and missing events
43 private Integer sequenceNumber;
46 * Specifies the type of the event. The type must be the full path to uniquely reference the event definition.
52 * Date and time when the event occurred in the system. Always available.
54 private String timestamp;
57 * @return the sequenceNumber
59 public Integer getSequenceNumber() {
60 return sequenceNumber;
64 * @return the timestamp
66 public String getTimestamp() {
73 public String getType() {
78 * @param sequenceNumber the sequenceNumber to set
80 public void setSequenceNumber(Integer sequenceNumber) {
81 this.sequenceNumber = sequenceNumber;
85 * @param timestamp the timestamp to set
87 public void setTimestamp(String timestamp) {
88 this.timestamp = timestamp;
92 * @param type the type to set
94 public void setType(String type) {
99 * Returns true, if the {@link EventDTO} is a ConfigChanged event.
101 * @return true if it is a ConfigChanged event, otherwise false
103 public boolean isConfigChangedEvent() {
104 return TYPE_CONFIGURATION_CHANGED.equals(getType());
108 * Returns true, if the {@link EventDTO} is a Disconnect event.
110 * @return true if it is a Disconnect event, otherwise false
112 public boolean isDisconnectedEvent() {
113 return TYPE_DISCONNECT.equals(getType());
117 * Returns true, if the {@link EventDTO} is a MessageDeletedEvent.
119 * @return true if it is a MessageDeleted event, otherwise false
121 public boolean isMessageDeletedEvent() {
122 return TYPE_MESSAGE_DELETED.equals(getType());
126 * Returns true, if the {@link EventDTO} is a NewMessageReceivedEvent.
128 * @return true if it is a MessageReceived event, otherwise false
130 public boolean isNewMessageReceivedEvent() {
131 return TYPE_NEW_MESSAGE_RECEIVED.equals(getType());
135 * Returns true, if the {@link EventDTO} is a StateChangedEvent.
137 * @return true if it is a StateChanged event, otherwise false
139 public boolean isStateChangedEvent() {
140 return TYPE_STATE_CHANGED.equals(getType());