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.homematic.internal.model;
15 import java.util.Objects;
18 * Simple representation of a datapoint.
20 * @author Gerhard Riegler - Initial contribution
22 public class HmDatapointInfo {
23 private String address;
24 private Integer channel;
26 private HmParamsetType paramsetType;
28 public HmDatapointInfo(HmDatapoint dp) {
29 this(dp.getParamsetType(), dp.getChannel(), dp.getName());
32 public HmDatapointInfo(HmParamsetType paramsetType, HmChannel channel, String name) {
33 this(channel.getDevice().getAddress(), paramsetType, channel.getNumber(), name);
36 public HmDatapointInfo(String address, HmParamsetType paramsetType, Integer channel, String name) {
37 this.address = address;
38 this.channel = channel;
39 this.paramsetType = paramsetType;
44 * Creates a values HmDatapointInfo.
46 public static HmDatapointInfo createValuesInfo(HmChannel channel, String name) {
47 return new HmDatapointInfo(HmParamsetType.VALUES, channel, name);
51 * Returns the address of the device.
53 public String getAddress() {
58 * Returns the channel number.
60 public Integer getChannel() {
65 * Returns the name of the datapoint.
67 public String getName() {
72 * Sets the name of the datapoint.
74 public void setName(String name) {
79 * Returns the paramset type.
81 public HmParamsetType getParamsetType() {
86 * Return true, if this is a pong datapoint info.
88 public boolean isPong() {
89 return "CENTRAL".equals(address) && "PONG".equals(name);
93 public int hashCode() {
94 return Objects.hash(address, paramsetType, channel, name);
98 public boolean equals(Object obj) {
99 if (!(obj instanceof HmDatapointInfo)) {
102 HmDatapointInfo comp = (HmDatapointInfo) obj;
103 return Objects.equals(address, comp.getAddress()) && Objects.equals(paramsetType, comp.getParamsetType())
104 && Objects.equals(channel, comp.getChannel()) && Objects.equals(name, comp.getName());
108 public String toString() {
109 if (paramsetType == HmParamsetType.VALUES) {
110 return String.format("%s:%s#%s", address, channel, name);
112 return String.format("%s:%s_%s#%s", address, paramsetType.getId(), channel, name);