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;
19 import java.util.stream.Collectors;
21 import org.eclipse.jdt.annotation.NonNullByDefault;
22 import org.eclipse.jdt.annotation.Nullable;
25 * The {@link AirQualityJsonData} is responsible for storing
26 * the "data" node from the waqi.org JSON response
28 * @author Kuba Wolanin - Initial contribution
31 public class AirQualityJsonData {
36 private @NonNullByDefault({}) AirQualityJsonTime time;
37 private @NonNullByDefault({}) AirQualityJsonCity city;
38 private List<Attribute> attributions = new ArrayList<>();
39 private Map<String, @Nullable AirQualityValue> iaqi = new HashMap<>();
40 private String dominentpol = "";
52 * Measuring Station ID
56 public int getStationId() {
61 * Receives "time" node from the "data" object in JSON response
63 * @return {AirQualityJsonTime}
65 public AirQualityJsonTime getTime() {
70 * Receives "city" node from the "data" object in JSON response
72 * @return {AirQualityJsonCity}
74 public AirQualityJsonCity getCity() {
79 * Collects a list of attributions (vendors making data available)
80 * and transforms it into readable string.
81 * Currently displayed in Thing Status description when ONLINE
85 public String getAttributions() {
86 String attributionsString = attributions.stream().map(Attribute::getName).collect(Collectors.joining(", "));
87 return "Attributions : " + attributionsString;
90 public String getDominentPol() {
94 public double getIaqiValue(String key) {
95 AirQualityValue result = iaqi.get(key);
97 return result.getValue();