2 * Copyright (c) 2010-2022 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.innogysmarthome.internal.client.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
24 public class BaseEvent {
26 public static final String TYPE_STATE_CHANGED = "StateChanged";// "device/SHC.RWE/1.0/event/StateChanged";
27 public static final String TYPE_NEW_MESSAGE_RECEIVED = "NewMessageReceived"; // "device/SHC.RWE/1.0/event/NewMessageReceived";
28 public static final String TYPE_MESSAGE_CREATED = "MessageCreated";
29 public static final String TYPE_MESSAGE_DELETED = "MessageDeleted"; // "device/SHC.RWE/1.0/event/MessageDeleted";
30 public static final String TYPE_DISCONNECT = "Disconnect"; // "/event/Disconnect";
31 public static final String TYPE_CONFIGURATION_CHANGED = "ConfigurationChanged"; // "device/SHC.RWE/1.0/event/ConfigChanged";
32 public static final String TYPE_CONTROLLER_CONNECTIVITY_CHANGED = "/event/ControllerConnectivityChanged"; // "device/SHC.RWE/1.0/event/ControllerConnectivityChanged";
33 public static final String TYPE_BUTTON_PRESSED = "ButtonPressed";
35 public static final Set<String> SUPPORTED_EVENT_TYPES = Collections
36 .unmodifiableSet(Stream.of(TYPE_STATE_CHANGED, TYPE_NEW_MESSAGE_RECEIVED, TYPE_MESSAGE_CREATED,
37 TYPE_MESSAGE_DELETED, TYPE_DISCONNECT, TYPE_CONFIGURATION_CHANGED,
38 TYPE_CONTROLLER_CONNECTIVITY_CHANGED, TYPE_BUTTON_PRESSED).collect(Collectors.toSet()));
41 * The event sequence number – the gateway keeps track and adds a sequence number to each event for the client to
42 * identify order and missing events
44 private Integer sequenceNumber;
47 * Specifies the type of the event. The type must be the full path to uniquely reference the event definition.
53 * Date and time when the event occurred in the system. Always available.
55 private String timestamp;
58 * @return the sequenceNumber
60 public Integer getSequenceNumber() {
61 return sequenceNumber;
65 * @return the timestamp
67 public String getTimestamp() {
74 public String getType() {
79 * @param sequenceNumber the sequenceNumber to set
81 public void setSequenceNumber(Integer sequenceNumber) {
82 this.sequenceNumber = sequenceNumber;
86 * @param timestamp the timestamp to set
88 public void setTimestamp(String timestamp) {
89 this.timestamp = timestamp;
93 * @param type the type to set
95 public void setType(String type) {
100 * Returns true, if the {@link Event} is a ConfigChanged event.
104 public boolean isConfigChangedEvent() {
105 return TYPE_CONFIGURATION_CHANGED.equals(getType());
109 * Returns true, if the {@link Event} is a ControllerConnectivityChanged event.
113 public boolean isControllerConnectivityChangedEvent() {
114 return TYPE_CONTROLLER_CONNECTIVITY_CHANGED.equals(getType());
118 * Returns true, if the {@link Event} is a Disconnect event.
122 public boolean isDisconnectedEvent() {
123 return TYPE_DISCONNECT.equals(getType());
127 * Returns true, if the {@link Event} is a MessageDeletedEvent.
131 public boolean isMessageDeletedEvent() {
132 return TYPE_MESSAGE_DELETED.equals(getType());
136 * Returns true, if the {@link Event} is a NewMessageReceivedEvent.
140 public boolean isNewMessageReceivedEvent() {
141 return TYPE_NEW_MESSAGE_RECEIVED.equals(getType());
145 * Returns true, if the {@link Event} is a StateChangedEvent.
149 public boolean isStateChangedEvent() {
150 return TYPE_STATE_CHANGED.equals(getType());