]> git.basschouten.com Git - openhab-addons.git/blob
45cb0e675e59a0562e446cd19e415589641c604b
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.fineoffsetweatherstation.internal.domain.response;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.openhab.binding.fineoffsetweatherstation.internal.domain.MeasureType;
18 import org.openhab.core.thing.type.ChannelTypeUID;
19 import org.openhab.core.types.State;
20
21 /**
22  * A certain measured value.
23  *
24  * @author Andreas Berger - Initial contribution
25  */
26 @NonNullByDefault
27 public class MeasuredValue {
28     private final MeasureType measureType;
29     private final String channelPrefix;
30     private final @Nullable Integer channelNumber;
31     private final @Nullable ChannelTypeUID channelTypeUID;
32     private final State state;
33     private final String debugName;
34
35     public MeasuredValue(MeasureType measureType, String channelPrefix, @Nullable Integer channelNumber,
36             @Nullable ChannelTypeUID channelTypeUID, State state, String debugName) {
37         this.measureType = measureType;
38         this.channelPrefix = channelPrefix;
39         this.channelNumber = channelNumber;
40         this.channelTypeUID = channelTypeUID;
41         this.state = state;
42         this.debugName = debugName;
43     }
44
45     public String getChannelId() {
46         return channelNumber == null ? channelPrefix : (channelPrefix + "-" + channelNumber);
47     }
48
49     public String getChannelPrefix() {
50         return channelPrefix;
51     }
52
53     public @Nullable Integer getChannelNumber() {
54         return channelNumber;
55     }
56
57     public @Nullable ChannelTypeUID getChannelTypeUID() {
58         return channelTypeUID;
59     }
60
61     public State getState() {
62         return state;
63     }
64
65     public String getDebugName() {
66         return debugName;
67     }
68
69     @Override
70     public String toString() {
71         return "MeasuredValue{" + "measureType=" + measureType + ", channelId='" + getChannelId() + '\''
72                 + ", channelTypeUID=" + channelTypeUID + ", state=" + state + ", debugName='" + debugName + '\'' + '}';
73     }
74 }