]> git.basschouten.com Git - openhab-addons.git/blob
0a7c9cda1b6f1a132da8dfce734a8b240f221242
[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.bluetooth.bluegiga.internal.enumeration;
14
15 import java.util.HashMap;
16 import java.util.Map;
17
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
20
21 /**
22  * Class to implement the BlueGiga Enumeration <b>SmpIoCapabilities</b>.
23  * <p>
24  * Security Manager I/O Capabilities
25  * <p>
26  * Note that this code is autogenerated. Manual changes may be overwritten.
27  *
28  * @author Chris Jackson - Initial contribution of Java code generator
29  */
30 @NonNullByDefault
31 public enum SmpIoCapabilities {
32     /**
33      * Default unknown value
34      */
35     UNKNOWN(-1),
36
37     /**
38      * [0] Display Only
39      */
40     SM_IO_CAPABILITY_DISPLAYONLY(0x0000),
41
42     /**
43      * [1] Display with Yes/No-buttons
44      */
45     SM_IO_CAPABILITY_DISPLAYYESNO(0x0001),
46
47     /**
48      * [2] Keyboard Only
49      */
50     SM_IO_CAPABILITY_KEYBOARDONLY(0x0002),
51
52     /**
53      * [3] No Input and No Output
54      */
55     SM_IO_CAPABILITY_NOINPUTNOOUTPUT(0x0003),
56
57     /**
58      * [4] Display with Keyboard
59      */
60     SM_IO_CAPABILITY_KEYBOARDDISPLAY(0x0004);
61
62     /**
63      * A mapping between the integer code and its corresponding type to
64      * facilitate lookup by code.
65      */
66     private static @Nullable Map<Integer, SmpIoCapabilities> codeMapping;
67
68     private int key;
69
70     private SmpIoCapabilities(int key) {
71         this.key = key;
72     }
73
74     /**
75      * Lookup function based on the type code. Returns {@link UNKNOWN} if the code does not exist.
76      *
77      * @param smpIoCapabilities
78      *            the code to lookup
79      * @return enumeration value.
80      */
81     public static SmpIoCapabilities getSmpIoCapabilities(int smpIoCapabilities) {
82         Map<Integer, SmpIoCapabilities> localCodeMapping = codeMapping;
83         if (localCodeMapping == null) {
84             localCodeMapping = new HashMap<>();
85             for (SmpIoCapabilities s : values()) {
86                 localCodeMapping.put(s.key, s);
87             }
88             codeMapping = localCodeMapping;
89         }
90
91         return localCodeMapping.getOrDefault(smpIoCapabilities, UNKNOWN);
92     }
93
94     /**
95      * Returns the BlueGiga protocol defined value for this enum
96      *
97      * @return the BGAPI enumeration key
98      */
99     public int getKey() {
100         return key;
101     }
102 }