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.netatmo.internal.api.dto;
15 import java.time.ZonedDateTime;
16 import java.util.Optional;
17 import java.util.stream.Stream;
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.eclipse.jdt.annotation.Nullable;
21 import org.openhab.binding.netatmo.internal.api.data.EventSubType;
22 import org.openhab.binding.netatmo.internal.api.data.EventType;
24 import com.google.gson.annotations.SerializedName;
27 * The {@link Event} holds information transferred by the webhook.
29 * @author Gaƫl L'hopital - Initial contribution
34 public abstract class Event extends NAObject {
35 protected EventType type = EventType.UNKNOWN;
36 @SerializedName(value = "camera_id", alternate = { "module_id" })
37 private String cameraId = "";
38 protected int subType = -1;
40 public abstract ZonedDateTime getTime();
42 public abstract @Nullable String getSnapshotUrl();
44 public abstract @Nullable String getPersonId();
46 public EventType getEventType() {
50 public String getCameraId() {
55 public @Nullable String getName() {
56 String localMessage = super.getName();
57 return (localMessage != null ? localMessage.replace("<b>", "").replace("</b>", "") : "");
60 public Optional<EventSubType> getSubTypeDescription() {
61 return Stream.of(EventSubType.values()).filter(v -> v.types.contains(getEventType()) && v.subType == subType)