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>BluetoothAddressType</b>.
24 * Bluetooth address types
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 BluetoothAddressType {
33 * Default unknown value
40 GAP_ADDRESS_TYPE_PUBLIC(0x0000),
45 GAP_ADDRESS_TYPE_RANDOM(0x0001);
48 * A mapping between the integer code and its corresponding type to
49 * facilitate lookup by code.
51 private static @Nullable Map<Integer, BluetoothAddressType> codeMapping;
55 private BluetoothAddressType(int key) {
60 * Lookup function based on the type code. Returns {@link UNKNOWN} if the code does not exist.
62 * @param bluetoothAddressType
64 * @return enumeration value.
66 public static BluetoothAddressType getBluetoothAddressType(int bluetoothAddressType) {
67 Map<Integer, BluetoothAddressType> localCodeMapping = codeMapping;
68 if (localCodeMapping == null) {
69 localCodeMapping = new HashMap<>();
70 for (BluetoothAddressType s : values()) {
71 localCodeMapping.put(s.key, s);
73 codeMapping = localCodeMapping;
76 return localCodeMapping.getOrDefault(bluetoothAddressType, UNKNOWN);
80 * Returns the BlueGiga protocol defined value for this enum
82 * @return the BGAPI enumeration key