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.device.cosem;
15 import java.text.ParseException;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.openhab.core.types.State;
21 * This CosemValueDescriptor provides meta data for a CosemValue
23 * @author M. Volaart - Initial contribution
26 abstract class CosemValueDescriptor<S extends State> {
29 * String describing the channel on which this value descriptor is available.
31 private final String channelId;
34 * Creates a new {@link CosemValueDescriptor} with no unit and a default channel.
36 public CosemValueDescriptor() {
41 * Creates a new {@link CosemValueDescriptor}.
43 * @param channelId the channel for this CosemValueDescriptor
45 public CosemValueDescriptor(String channelId) {
46 this.channelId = channelId;
50 * Parses the string value to the {@link State} value
52 * @param CosemValue the Cosem value to parse
53 * @return S the {@link State} object instance of the Cosem value
54 * @throws ParseException if parsing failed
56 protected abstract S getStateValue(String cosemValue) throws ParseException;
59 * Returns the channel id for this {@link CosemValueDescriptor}
61 * @return the channel identifier
63 public String getChannelId() {
68 * Returns String representation of this {@link CosemValueDescriptor}
70 * @return String representation of this {@link CosemValueDescriptor}
73 public String toString() {
74 return "CosemValueDescriptor[channel=" + channelId + "]";