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