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;
19 * Class to implement the BlueGiga Enumeration <b>AttributeChangeReason</b>.
21 * This enumeration contains the reason for an attribute value change.
23 * Note that this code is autogenerated. Manual changes may be overwritten.
25 * @author Chris Jackson - Initial contribution of Java code generator
27 public enum AttributeChangeReason {
29 * Default unknown value
34 * [0] Value was written by remote device using write request
36 ATTRIBUTES_ATTRIBUTE_CHANGE_REASON_WRITE_REQUEST(0x0000),
39 * [1] Value was written by remote device using write command
41 ATTRIBUTES_ATTRIBUTE_CHANGE_REASON_WRITE_COMMAND(0x0001),
44 * [2] Local attribute value was written by the remote device, but the Smart Bluetooth stack is
45 * waiting for the write to be confirmed by the application. User Write Response command should
46 * be used to send the confirmation. For this reason to appear the attribute in the GATT database
47 * must have the user property enabled. See Profile Toolkit Developer Guide for more
48 * information how to enable the user property for an attribute.
50 ATTRIBUTES_ATTRIBUTE_CHANGE_REASON_WRITE_REQUEST_USER(0x0002);
53 * A mapping between the integer code and its corresponding type to
54 * facilitate lookup by code.
56 private static Map<Integer, AttributeChangeReason> codeMapping;
60 private AttributeChangeReason(int key) {
64 private static void initMapping() {
65 codeMapping = new HashMap<>();
66 for (AttributeChangeReason s : values()) {
67 codeMapping.put(s.key, s);
72 * Lookup function based on the type code. Returns null if the code does not exist.
74 * @param attributeChangeReason
76 * @return enumeration value.
78 public static AttributeChangeReason getAttributeChangeReason(int attributeChangeReason) {
79 if (codeMapping == null) {
83 if (codeMapping.get(attributeChangeReason) == null) {
87 return codeMapping.get(attributeChangeReason);
91 * Returns the BlueGiga protocol defined value for this enum
93 * @return the BGAPI enumeration key