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 static java.util.Objects.requireNonNull;
16 import static org.openhab.binding.echonetlite.internal.HexUtil.hex;
18 import java.net.InetSocketAddress;
19 import java.util.Objects;
21 import org.eclipse.jdt.annotation.NonNullByDefault;
22 import org.eclipse.jdt.annotation.Nullable;
25 * @author Michael Barker - Initial contribution
28 public class InstanceKey {
29 final InetSocketAddress address;
30 final EchonetClass klass;
33 public InstanceKey(final InetSocketAddress address, final EchonetClass klass, final int instance) {
34 this.address = requireNonNull(address);
35 this.klass = requireNonNull(klass);
36 this.instance = instance;
40 public String toString() {
41 return "InstanceKey{" + "address=" + address + ", klass=" + klass + ", instance=" + instance + '}';
44 public String representationProperty() {
45 return address.getAddress().getHostAddress() + "_" + hex(klass.groupCode()) + ":" + hex(klass.classCode()) + ":"
50 public boolean equals(@Nullable final Object o) {
54 if (o == null || getClass() != o.getClass()) {
57 final InstanceKey that = (InstanceKey) o;
58 return instance == that.instance && address.equals(that.address) && klass == that.klass;
62 public int hashCode() {
63 return Objects.hash(address, klass, instance);