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.digitalstrom.internal.lib.structure.impl;
15 import java.util.HashMap;
18 import org.openhab.binding.digitalstrom.internal.lib.serverconnection.constants.JSONApiResponseKeysEnum;
19 import org.openhab.binding.digitalstrom.internal.lib.structure.Apartment;
20 import org.openhab.binding.digitalstrom.internal.lib.structure.Zone;
22 import com.google.gson.JsonArray;
23 import com.google.gson.JsonObject;
26 * The {@link JSONApartmentImpl} is the implementation of the {@link Apartment}.
28 * @author Alexander Betker - Initial contribution
29 * @author Michael Ochel - change from SimpleJSON to GSON
30 * @author Matthias Siegele - change from SimpleJSON to GSON
32 public class JSONApartmentImpl implements Apartment {
34 private Map<Integer, Zone> zoneMap = new HashMap<>();
37 * Creates a new {@link JSONApartmentImpl} through the {@link JsonObject}.
39 * @param jObject of the server response, must not be null
41 public JSONApartmentImpl(JsonObject jObject) {
42 if (jObject.get(JSONApiResponseKeysEnum.ZONES.getKey()) instanceof JsonArray) {
43 JsonArray zones = (JsonArray) jObject.get(JSONApiResponseKeysEnum.ZONES.getKey());
44 for (int i = 0; i < zones.size(); i++) {
45 if (zones.get(i) instanceof JsonObject) {
46 Zone zone = new JSONZoneImpl((JsonObject) zones.get(i));
47 zoneMap.put(zone.getZoneId(), zone);
54 public Map<Integer, Zone> getZoneMap() {