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