]> git.basschouten.com Git - openhab-addons.git/blob
af6d6584c188f2d0b0cd2e1f678f682717046e37
[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.venstarthermostat.internal.dto;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16
17 /**
18  * The {@link VenstarScheduleMode} represents the value of the schedule mode returned
19  * from the REST API.
20  *
21  * @author Matthew Davies - Initial contribution
22  */
23 @NonNullByDefault
24 public enum VenstarScheduleMode {
25     DISABLED(0, "disabled", "Disabled"),
26     ENABLED(1, "enabled", "Enabled");
27
28     private int mode;
29     private String name;
30     private String friendlyName;
31
32     VenstarScheduleMode(int mode, String name, String friendlyName) {
33         this.mode = mode;
34         this.name = name;
35         this.friendlyName = friendlyName;
36     }
37
38     public int mode() {
39         return mode;
40     }
41
42     public String modeName() {
43         return name;
44     }
45
46     public String friendlyName() {
47         return friendlyName;
48     }
49
50     public static VenstarScheduleMode fromInt(int mode) throws IllegalArgumentException {
51         for (VenstarScheduleMode sm : values()) {
52             if (sm.mode == mode) {
53                 return sm;
54             }
55         }
56
57         throw (new IllegalArgumentException("Invalid schedule mode " + mode));
58     }
59 }