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.digitalstrom.internal.lib.structure.devices.deviceparameters.impl;
16 * The {@link DSID} represents the digitalSTROM-Device identifier.
18 * @author Alexander Betker - Initial contribution
19 * @author Alexander Friese - simplified constructor
23 private final String dsid;
24 private static final String DEFAULT_DSID = "3504175fe000000000000001";
25 private static final String PRE = "3504175fe0000000";
26 private static final String ALL = "ALL";
29 * Creates a new {@link DSID}.
31 * @param dsid to create
33 public DSID(String dsid) {
34 var trimmedDsid = dsid != null ? dsid.trim() : "";
35 if (trimmedDsid.length() == 24) {
36 this.dsid = trimmedDsid;
37 } else if (trimmedDsid.length() == 8) {
38 this.dsid = PRE + trimmedDsid;
39 } else if (trimmedDsid.toUpperCase().equals(ALL)) {
42 this.dsid = DEFAULT_DSID;
47 * Returns the dSID as {@link String}.
51 public String getValue() {
56 public boolean equals(Object obj) {
57 if (obj instanceof DSID) {
58 return ((DSID) obj).getValue().equals(this.getValue());
64 public int hashCode() {
65 return dsid.hashCode();
69 public String toString() {