2 * Copyright (c) 2010-2020 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.nibeuplink.internal.model;
15 import java.util.ArrayList;
16 import java.util.HashMap;
17 import java.util.List;
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.eclipse.jdt.annotation.Nullable;
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
25 import com.google.gson.annotations.SerializedName;
28 * data class to map the json status response
30 * @author Alexander Friese - initial contribution
33 public class GenericDataResponse implements DataResponse {
34 private final Logger logger = LoggerFactory.getLogger(GenericDataResponse.class);
37 public static class Value {
38 @SerializedName("VariableId")
39 private @Nullable String variableId;
40 @SerializedName("CurrentValue")
41 private @Nullable String currentValue;
42 @SerializedName("CurrentIntValue")
43 private @Nullable Long currentIntValue;
44 @SerializedName("IsLoading")
45 private boolean isLoading;
48 @SerializedName("IsOffline")
49 private @Nullable String isOffline;
50 @SerializedName("OnlineImage")
51 private @Nullable String onlineImage;
52 @SerializedName("Date")
53 private @Nullable String date;
54 @SerializedName("FuzzyDate")
55 private @Nullable String fuzzyDate;
56 @SerializedName("Values")
57 private List<Value> values = new ArrayList<>();
60 public Map<String, @Nullable Long> getValues() {
61 Map<String, @Nullable Long> valueMap = new HashMap<>();
62 for (Value value : values) {
63 String id = value.variableId;
64 if (!value.isLoading && id != null) {
65 if (logger.isDebugEnabled()) {
66 logger.debug("Channel {} updated to: {} ({})", value.variableId, value.currentIntValue,
69 valueMap.put(id, value.currentIntValue);
75 public @Nullable String getIsOffline() {
79 public @Nullable String getOnlineImage() {
83 public @Nullable String getDate() {
87 public @Nullable String getFuzzyDate() {