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.openthermgateway.internal;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.openhab.core.types.State;
20 * The {@link DataItem} represents the base dataitem.
22 * @author Arjen Korevaar - Initial contribution
26 public abstract class DataItem {
28 private ByteType byteType;
29 private String subject;
30 private @Nullable CodeType codeType;
36 public ByteType getByteType() {
40 public String getSubject() {
44 public @Nullable CodeType getCodeType() {
48 public DataItem(Msg msg, ByteType byteType, String subject, @Nullable CodeType codeType) {
50 this.byteType = byteType;
51 this.subject = subject;
52 this.codeType = codeType;
55 public boolean hasValidCodeType(Message message) {
56 // Used to bind a dataitem to a specific TBRA code
58 CodeType code = this.getCodeType();
60 return (code == null || code == message.getCodeType());
64 * @param message unused in this default implementation
65 * @return the channel id
67 public String getChannelId(Message message) {
68 // Default implementation
72 public abstract State createState(Message message);