2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.bluetooth.bluegiga.internal.enumeration;
15 import java.util.HashMap;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
22 * Class to implement the BlueGiga Enumeration <b>GapConnectableMode</b>.
24 * GAP connectable modes
26 * Note that this code is autogenerated. Manual changes may be overwritten.
28 * @author Chris Jackson - Initial contribution of Java code generator
31 public enum GapConnectableMode {
33 * Default unknown value
40 GAP_NON_CONNECTABLE(0x0000),
43 * [1] Directed Connectable
45 GAP_DIRECTED_CONNECTABLE(0x0001),
48 * [2] Undirected connectable
50 GAP_UNDIRECTED_CONNECTABLE(0x0002),
53 * [3] Same as non-connectable, but also supports ADV_SCAN_IND packets. Device accepts scan
54 * requests (active scanning) but is not connectable.
56 GAP_SCANNABLE_NON_CONNECTABLE(0x0003);
59 * A mapping between the integer code and its corresponding type to
60 * facilitate lookup by code.
62 private static @Nullable Map<Integer, GapConnectableMode> codeMapping;
66 private GapConnectableMode(int key) {
71 * Lookup function based on the type code. Returns {@link UNKNOWN} if the code does not exist.
73 * @param gapConnectableMode
75 * @return enumeration value.
77 public static GapConnectableMode getGapConnectableMode(int gapConnectableMode) {
78 Map<Integer, GapConnectableMode> localCodeMapping = codeMapping;
79 if (localCodeMapping == null) {
80 localCodeMapping = new HashMap<>();
81 for (GapConnectableMode s : values()) {
82 localCodeMapping.put(s.key, s);
84 codeMapping = localCodeMapping;
87 return localCodeMapping.getOrDefault(gapConnectableMode, UNKNOWN);
91 * Returns the BlueGiga protocol defined value for this enum
93 * @return the BGAPI enumeration key