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.dsmr.internal.meter;
15 import java.util.Objects;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
21 * The DSMRMeterDescriptor describes a meter.
23 * A DSMR Meter consists of the following properties:
28 * @author M. Volaart - Initial contribution
31 public class DSMRMeterDescriptor {
35 private final DSMRMeterType meterType;
40 private final int channel;
43 * Constructor for new DSMRMeterDescriptor
45 * @param meterType The meter type
46 * @param channel The M-Bus channel this meter is connected to
48 public DSMRMeterDescriptor(DSMRMeterType meterType, int channel) {
49 this.meterType = meterType;
50 this.channel = channel;
54 * @return the meterType
56 public DSMRMeterType getMeterType() {
63 public int getChannel() {
68 * @return the id to identify of channel as String or as "default" is its the unknown channel.
70 public String getChannelId() {
71 return channel == DSMRMeterConstants.UNKNOWN_CHANNEL ? "default" : String.valueOf(channel);
75 * Returns true if both DSMRMeterDescriptor are equal. I.e.:
76 * - meterType is the same
77 * - channel is the same
78 * - identification is the same
80 * @param other DSMRMeterDescriptor to check
81 * @return true if both objects are equal, false otherwise
84 public boolean equals(@Nullable Object other) {
85 if (!(other instanceof DSMRMeterDescriptor)) {
88 DSMRMeterDescriptor o = (DSMRMeterDescriptor) other;
90 return meterType == o.meterType && channel == o.channel;
94 public int hashCode() {
95 return Objects.hash(meterType, channel);
99 public String toString() {
100 return "[Meter type: " + meterType + ", channel: " + channel + ']';