]> git.basschouten.com Git - openhab-addons.git/blob
97854d0e424eb5bd7059ec1bfc30ad4bb33ee512
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.zoneminder.internal.handler;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17
18 import com.google.gson.annotations.SerializedName;
19
20 /**
21  * The {@link MonitorState} represents the possible states of a Zoneminder monitor.
22  *
23  * @author Mark Hilbush - Initial contribution
24  */
25 @NonNullByDefault
26 public enum MonitorState {
27
28     @SerializedName("0")
29     IDLE("IDLE"),
30
31     @SerializedName("1")
32     PREALERT("PREALERT"),
33
34     @SerializedName("2")
35     ALARM("ALARM"),
36
37     @SerializedName("3")
38     ALERT("ALERT"),
39
40     @SerializedName("4")
41     TAPE("TAPE"),
42
43     UNKNOWN("UNKNOWN");
44
45     private final String type;
46
47     private MonitorState(String type) {
48         this.type = type;
49     }
50
51     public static MonitorState forValue(@Nullable String v) {
52         if (v != null) {
53             for (MonitorState at : MonitorState.values()) {
54                 if (at.type.equals(v)) {
55                     return at;
56                 }
57             }
58         }
59         throw new IllegalArgumentException(String.format("Invalid or null monitor state: %s" + v));
60     }
61
62     @Override
63     public String toString() {
64         return this.type;
65     }
66 }