2 * Copyright (c) 2010-2023 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.siemensrds.internal;
15 import java.util.List;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
22 import com.google.gson.Gson;
23 import com.google.gson.annotations.SerializedName;
27 * Interface to the Plants List of a particular User
29 * @author Andrew Fiddian-Green - Initial contribution
33 public class RdsPlants {
35 protected final Logger logger = LoggerFactory.getLogger(RdsPlants.class);
37 @SerializedName("items")
38 private @Nullable List<PlantInfo> plants;
40 private static final Gson GSON = new Gson();
42 @SuppressWarnings("null")
44 public static class PlantInfo {
47 private @Nullable String plantId;
48 @SerializedName("isOnline")
49 private boolean online;
51 public String getId() throws RdsCloudException {
52 String plantId = this.plantId;
53 if (plantId != null) {
56 throw new RdsCloudException("plant has no Id");
59 public boolean isOnline() {
65 * public method: parse JSON, and create a class that encapsulates the data
67 public static @Nullable RdsPlants createFromJson(String json) {
68 return GSON.fromJson(json, RdsPlants.class);
72 * public method: return the plant list
74 public @Nullable List<PlantInfo> getPlants() {