]> git.basschouten.com Git - openhab-addons.git/blob
ab71bd2a322622e2dc7a3a7f90dbd568bbfe61c3
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 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.netatmo.internal.api;
14
15 import java.util.Collection;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
19 import org.openhab.binding.netatmo.internal.api.dto.NAObject;
20 import org.openhab.binding.netatmo.internal.deserialization.NAObjectMap;
21
22 import com.google.gson.annotations.SerializedName;
23
24 /**
25  * The {@link ListBodyResponse} models a response returned by API call containing
26  * a list of elements.
27  *
28  * @author GaĆ«l L'hopital - Initial contribution
29  *
30  */
31 @NonNullByDefault
32 public class ListBodyResponse<T extends NAObject> {
33     @SerializedName(value = "devices", alternate = { "homes", "events_list", "events" })
34     private NAObjectMap<T> elements = new NAObjectMap<>();
35
36     @Nullable
37     T getElement(String id) {
38         return elements.get(id);
39     }
40
41     public Collection<T> getElements() {
42         return elements.values();
43     }
44 }