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.echonetlite.internal;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
18 * @author Michael Barker - Initial contribution
21 public enum EchonetClass {
22 AIRCON_HOMEAC(0x01, 0x30, (Epc[]) Epc.Device.values(), (Epc[]) Epc.AcGroup.values(), (Epc[]) Epc.HomeAc.values()),
23 MANAGEMENT_CONTROLLER(0x05, 0xFF, new Epc[0], new Epc[0], new Epc[0]),
24 NODE_PROFILE(0x0e, 0xf0, (Epc[]) Epc.Profile.values(), (Epc[]) Epc.ProfileGroup.values(),
25 (Epc[]) Epc.NodeProfile.values());
27 private final int groupCode;
28 private final int classCode;
29 private final Epc[] deviceProperties;
30 private final Epc[] groupProperties;
31 private final Epc[] classProperties;
33 EchonetClass(final int groupCode, final int classCode, Epc[] deviceProperties, Epc[] groupProperties,
34 Epc[] classProperties) {
35 this.groupCode = groupCode;
36 this.classCode = classCode;
37 this.deviceProperties = deviceProperties;
38 this.groupProperties = groupProperties;
39 this.classProperties = classProperties;
42 public static EchonetClass resolve(final int groupCode, final int classCode) {
43 final EchonetClass[] values = values();
44 for (EchonetClass value : values) {
45 if (value.groupCode == groupCode && value.classCode == classCode) {
50 throw new IllegalArgumentException("Unable to find class: " + groupCode + "/" + classCode);
53 public int groupCode() {
57 public int classCode() {
61 Epc[] deviceProperties() {
62 return deviceProperties;
65 Epc[] groupProperties() {
66 return groupProperties;
69 Epc[] classProperties() {
70 return classProperties;
73 public String toString() {
74 return name() + "{" + "groupCode=0x" + Integer.toHexString(groupCode) + ", classCode=0x"
75 + Integer.toHexString(0xFF & classCode) + '}';