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.satel.internal.event;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
19 * Event class describing connection status to Satel module.
21 * @author Krzysztof Goworek - Initial contribution
24 public class ConnectionStatusEvent implements SatelEvent {
26 private boolean connected;
28 private @Nullable String reason;
31 * Constructs event class with given connection status.
33 * @param connected value describing connection status
35 public ConnectionStatusEvent(boolean connected) {
36 this(connected, null);
40 * Constructs event class with given connection status and disconnection reason.
42 * @param connected value describing connection status
43 * @param reason disconnection reason
45 public ConnectionStatusEvent(boolean connected, @Nullable String reason) {
46 this.connected = connected;
51 * Returns status of connection.
53 * @return a boolean value describing connection status
55 public boolean isConnected() {
56 return this.connected;
60 * Returns disconnection reason.
62 * @return optional text description in case of disconnection
64 public @Nullable String getReason() {
69 public String toString() {
70 return String.format("%s: connected = %b, reason = %s", this.getClass().getName(), this.connected, this.reason);