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.onewire.internal.owserver;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.openhab.binding.onewire.internal.SensorId;
20 * The {@link OwserverDeviceParameter} device parameter definition for owserver bridge handler
22 * @author Jan N. Klug - Initial contribution
26 public class OwserverDeviceParameter {
27 private String prefix = "";
28 private String path = "";
31 * device parameter for owserver bridge handler
33 * @param prefix path prefix (e.g. "uncached/")
34 * @param path path without sensor id (e.g. "/humidity")
36 public OwserverDeviceParameter(String prefix, String path) {
37 if (prefix.endsWith("/")) {
38 this.prefix = prefix.substring(0, prefix.length() - 1);
42 if (this.prefix.startsWith("/")) {
43 this.prefix = this.prefix.substring(1);
45 if (path.startsWith("/")) {
48 this.path = "/" + path;
53 * device parameter for owserver bridge handler
55 * @param path path without sensor id (e.g. "/humidity")
57 public OwserverDeviceParameter(String path) {
62 * get the full owfs path for a given sensor id
66 public String getPath(SensorId sensorId) {
67 return prefix + sensorId.getFullPath() + path;
71 public String toString() {
72 return prefix + "/sensorId" + path;
76 public int hashCode() {
77 return toString().hashCode();
81 public boolean equals(@Nullable Object o) {
86 if (!(o instanceof OwserverDeviceParameter)) {
90 return ((OwserverDeviceParameter) o).toString().equals(toString());