]> git.basschouten.com Git - openhab-addons.git/blob
565b5f798faf8710d439fc073cb6e7c3b031b7f8
[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.hdanywhere.internal;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.core.thing.ThingTypeUID;
17
18 /**
19  * The {@link HDanywhereBinding} class defines common constants, which are used
20  * across the whole binding.
21  *
22  * @author Karel Goderis - Initial contribution
23  */
24 @NonNullByDefault
25 public class HDanywhereBindingConstants {
26
27     public static final String BINDING_ID = "hdanywhere";
28
29     // List of all Thing Type UIDs
30     public static final ThingTypeUID THING_TYPE_MULTIROOMPLUS = new ThingTypeUID(BINDING_ID, "multiroomplus");
31     public static final ThingTypeUID THING_TYPE_MHUB4K431 = new ThingTypeUID(BINDING_ID, "mhub4k431");
32
33     // List of all Channel ids
34     public enum Port {
35         ONE(1, "port1"),
36         TWO(2, "port2"),
37         THREE(3, "port3"),
38         FOUR(4, "port4"),
39         FIVE(5, "port5"),
40         SIX(6, "port6"),
41         SEVEN(7, "port7"),
42         EIGHT(8, "port8");
43
44         private final int number;
45         private final String id;
46
47         private Port(final int number, final String id) {
48             this.number = number;
49             this.id = id;
50         }
51
52         @Override
53         public String toString() {
54             return String.valueOf(number);
55         }
56
57         public int toNumber() {
58             return number;
59         }
60
61         public static Port get(int valueSelectorNumber) throws IllegalArgumentException {
62             for (Port c : Port.values()) {
63                 if (c.number == valueSelectorNumber) {
64                     return c;
65                 }
66             }
67
68             throw new IllegalArgumentException("Not valid value selector");
69         }
70
71         public static Port get(String valueSelectorText) throws IllegalArgumentException {
72             for (Port c : Port.values()) {
73                 if (c.id.equals(valueSelectorText)) {
74                     return c;
75                 }
76             }
77
78             throw new IllegalArgumentException("Not valid value selector");
79         }
80
81         public String channelID() {
82             return this.id;
83         }
84     }
85 }