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>ScanResponseType</b>.
24 * Defines the packet types received during a scan response
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 ScanResponseType {
33 * Default unknown value
38 * [0] Connectable Advertisement packet
40 CONNECTABLE_ADVERTISEMENT(0x0000),
43 * [2] Non Connectable Advertisement packet
45 NON_CONNECTABLE_ADVERTISEMENT(0x0002),
48 * [4] Scan response packet
50 SCAN_RESPONSE(0x0004),
53 * [6] Discoverable advertisement packet
55 DISCOVERABLE_ADVERTISEMENT(0x0006);
58 * A mapping between the integer code and its corresponding type to
59 * facilitate lookup by code.
61 private static @Nullable Map<Integer, ScanResponseType> codeMapping;
65 private ScanResponseType(int key) {
70 * Lookup function based on the type code. Returns {@link UNKNOWN} if the code does not exist.
72 * @param scanResponseType
74 * @return enumeration value.
76 public static ScanResponseType getScanResponseType(int scanResponseType) {
77 Map<Integer, ScanResponseType> localCodeMapping = codeMapping;
78 if (localCodeMapping == null) {
79 localCodeMapping = new HashMap<>();
80 for (ScanResponseType s : values()) {
81 localCodeMapping.put(s.key, s);
83 codeMapping = localCodeMapping;
86 return localCodeMapping.getOrDefault(scanResponseType, UNKNOWN);
90 * Returns the BlueGiga protocol defined value for this enum
92 * @return the BGAPI enumeration key