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 org.openhab.binding.livisismarthome.internal.client.api.entity.link.LinkDTO;
16 import org.openhab.binding.livisismarthome.internal.client.api.entity.message.MessageDTO;
19 * Defines the {@link EventDTO}, which is sent by the LIVISI websocket to inform the clients about changes.
21 * @author Oliver Kuhl - Initial contribution
23 public class MessageEventDTO extends BaseEventDTO {
26 * Reference to the associated entity (instance or metadata) for the given event. Always available.
28 private String source;
31 * The product (context) that generated the event.
33 private String namespace;
36 * Data for the event, The data container can contain any type of entity dependent on the event type. For example,
37 * the DeviceFound events contains the entire Device entity rather than selected properties.
40 private MessageDTO data;
43 * @return the link to the source
45 public String getSource() {
50 * @param source the link to the source to set
52 public void setSource(String source) {
57 * @return the namespace
59 public String getNamespace() {
64 * @param namespace the namespace to set
66 public void setNamespace(String namespace) {
67 this.namespace = namespace;
71 * @return the dataList
73 public MessageDTO getData() {
78 * @param data the data to set
80 public void setData(MessageDTO data) {
84 public MessageDTO getMessage() {
89 * Returns the id of the link or null, if there is no link or the link does not have an id.
91 * @return String the id of the link or null
93 public String getSourceId() {
95 final String linkType = getSourceLinkType();
96 if (linkType != null && !LinkDTO.LINK_TYPE_UNKNOWN.equals(linkType)
97 && !LinkDTO.LINK_TYPE_SHC.equals(linkType)) {
98 return source.replace(linkType, "");
105 * Returns the Type of the {@link LinkDTO} in the {@link EventDTO}.
107 * @return type of the {@link LinkDTO}
109 private String getSourceLinkType() {
110 if (source != null) {
111 return LinkDTO.getLinkType(source);