]> git.basschouten.com Git - openhab-addons.git/blob
33b79d92d7df4ce4f45cca4faae29a5deadfbe37
[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 VenstarSchedulePart} represents the schedule part (part of day) returned
19  * from the REST API.
20  *
21  * @author Matthew Davies - Initial contribution
22  */
23 @NonNullByDefault
24 public enum VenstarSchedulePart {
25     MORNING(0, "morning", "Morning"),
26     DAY(1, "day", "Day"),
27     EVENING(2, "evening", "Evening"),
28     NIGHT(3, "night", "Night"),
29     INACTIVE(255, "inactive", "Inactive");
30
31     private int part;
32     private String name;
33     private String friendlyName;
34
35     VenstarSchedulePart(int part, String name, String friendlyName) {
36         this.part = part;
37         this.name = name;
38         this.friendlyName = friendlyName;
39     }
40
41     public int part() {
42         return part;
43     }
44
45     public String partName() {
46         return name;
47     }
48
49     public String friendlyName() {
50         return friendlyName;
51     }
52
53     public static VenstarSchedulePart fromInt(int part) throws IllegalArgumentException {
54         for (VenstarSchedulePart sp : values()) {
55             if (sp.part == part) {
56                 return sp;
57             }
58         }
59
60         throw (new IllegalArgumentException("Invalid schedule part " + part));
61     }
62 }