]> git.basschouten.com Git - openhab-addons.git/blob
cebba312986eadee01990c28a1df32c16a489fa2
[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.sleepiq.internal.api.enums;
14
15 import static org.openhab.binding.sleepiq.internal.SleepIQBindingConstants.*;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18
19 import com.google.gson.annotations.SerializedName;
20
21 /**
22  * The {@link FoundationActuator} represents actuators at the head and foot of the bed side.
23  *
24  * @author Mark Hilbush - Initial contribution
25  */
26 @NonNullByDefault
27 public enum FoundationActuator {
28     @SerializedName("H")
29     HEAD("H"),
30
31     @SerializedName("F")
32     FOOT("F");
33
34     private final String actuator;
35
36     FoundationActuator(final String actuator) {
37         this.actuator = actuator;
38     }
39
40     public String value() {
41         return actuator;
42     }
43
44     public static FoundationActuator forValue(String value) {
45         for (FoundationActuator s : FoundationActuator.values()) {
46             if (s.actuator.equals(value)) {
47                 return s;
48             }
49         }
50         throw new IllegalArgumentException("Invalid actuator: " + value);
51     }
52
53     public static FoundationActuator convertFromChannelId(String channelId) {
54         FoundationActuator localActuator;
55         switch (channelId) {
56             case CHANNEL_RIGHT_POSITION_HEAD:
57             case CHANNEL_LEFT_POSITION_HEAD:
58                 localActuator = FoundationActuator.HEAD;
59                 break;
60             case CHANNEL_RIGHT_POSITION_FOOT:
61             case CHANNEL_LEFT_POSITION_FOOT:
62                 localActuator = FoundationActuator.FOOT;
63                 break;
64             default:
65                 throw new IllegalArgumentException("Can't convert channel to actuator: " + channelId);
66         }
67         return localActuator;
68     }
69
70     @Override
71     public String toString() {
72         return actuator;
73     }
74 }