]> git.basschouten.com Git - openhab-addons.git/blob
3c391b97bd8836571fad0448b6edc527b4143a52
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2021 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.hdpowerview.internal.api.responses;
14
15 import java.util.List;
16 import java.util.StringJoiner;
17
18 import com.google.gson.annotations.SerializedName;
19
20 /**
21  * Survey data of a single Shade, as returned by an HD PowerView hub
22  *
23  * @author Jacob Laursen - Initial contribution
24  */
25 public class Survey {
26     @SerializedName("shade_id")
27     public int shadeId;
28     @SerializedName("survey")
29     public List<SurveyData> surveyData;
30
31     public static class SurveyData {
32         @SerializedName("neighbor_id")
33         public int neighborId;
34         public int rssi;
35
36         @Override
37         public String toString() {
38             return String.format("{neighbor id:%d, rssi:%d}", neighborId, rssi);
39         }
40     }
41
42     @Override
43     public String toString() {
44         if (surveyData == null) {
45             return "{}";
46         }
47         StringJoiner joiner = new StringJoiner(", ");
48         surveyData.forEach(data -> joiner.add(data.toString()));
49         return joiner.toString();
50     }
51 }