2 * Copyright (c) 2010-2024 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.insteon.internal.driver;
15 import java.util.ArrayList;
16 import java.util.Collections;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
20 import org.openhab.binding.insteon.internal.device.InsteonAddress;
21 import org.openhab.binding.insteon.internal.message.Msg;
22 import org.openhab.binding.insteon.internal.utils.Utils;
25 * The ModemDBEntry class holds a modem device type record
28 * @author Bernd Pfrommer - Initial contribution
29 * @author Rob Nielsen - Port to openHAB 2 insteon binding
32 public class ModemDBEntry {
33 private @Nullable InsteonAddress address = null;
34 private boolean isModem;
35 private @Nullable Port port = null;
36 private ArrayList<Msg> linkRecords = new ArrayList<>();
37 private ArrayList<Byte> controls = new ArrayList<>();
38 private ArrayList<Byte> respondsTo = new ArrayList<>();
40 public ModemDBEntry(InsteonAddress aAddr, boolean isModem) {
42 this.isModem = isModem;
45 public boolean isModem() {
49 public ArrayList<Msg> getLinkRecords() {
53 public void addLinkRecord(Msg m) {
57 public void addControls(byte c) {
61 public ArrayList<Byte> getControls() {
65 public void addRespondsTo(byte r) {
69 public ArrayList<Byte> getRespondsTo() {
73 public void setPort(Port p) {
77 public @Nullable Port getPort() {
82 public String toString() {
83 String s = "addr:" + address + "|controls:[" + toGroupString(controls) + "]|responds_to:["
84 + toGroupString(respondsTo) + "]|link_recors";
85 for (Msg m : linkRecords) {
91 private String toGroupString(ArrayList<Byte> group) {
92 ArrayList<Byte> sorted = new ArrayList<>(group);
93 Collections.sort(sorted);
95 StringBuilder buf = new StringBuilder();
96 for (Byte b : sorted) {
97 if (buf.length() > 0) {
101 buf.append(Utils.getHexString(b));
104 return buf.toString();