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.airquality.internal.json;
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;
24 * The {@link AirQualityJsonData} is responsible for storing
25 * the "data" node from the waqi.org JSON response
27 * @author Kuba Wolanin - Initial contribution
30 public class AirQualityJsonData {
35 private @NonNullByDefault({}) AirQualityJsonTime time;
36 private @NonNullByDefault({}) AirQualityJsonCity city;
37 private List<Attribute> attributions = new ArrayList<>();
38 private Map<String, @Nullable AirQualityValue> iaqi = new HashMap<>();
39 private String dominentpol = "";
51 * Measuring Station ID
55 public int getStationId() {
60 * Receives "time" node from the "data" object in JSON response
62 * @return {AirQualityJsonTime}
64 public AirQualityJsonTime getTime() {
69 * Receives "city" node from the "data" object in JSON response
71 * @return {AirQualityJsonCity}
73 public AirQualityJsonCity getCity() {
78 * Collects a list of attributions (vendors making data available)
79 * and transforms it into readable string.
80 * Currently displayed in Thing Status description when ONLINE
84 public String getAttributions() {
85 List<String> list = new ArrayList<>();
86 attributions.forEach(item -> list.add(item.getName()));
87 return "Attributions : " + String.join(", ", list);
90 public String getDominentPol() {
94 public double getIaqiValue(String key) {
95 AirQualityValue result = iaqi.get(key);
97 return result.getValue();