]> git.basschouten.com Git - openhab-addons.git/blob
18c237027f0993209dd19197e603bcab7c024db2
[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.surepetcare.internal.dto;
14
15 import java.util.ArrayList;
16 import java.util.List;
17
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
20
21 /**
22  * The {@link SurePetcareTopology} is the Java class used to represent a whole Sure Petcare topology. It's used to
23  * deserialize JSON API results.
24  *
25  * @author Rene Scherer - Initial contribution
26  */
27 @NonNullByDefault
28 public class SurePetcareTopology {
29
30     public List<SurePetcareDevice> devices = new ArrayList<>();
31     public List<SurePetcareHousehold> households = new ArrayList<>();
32     public List<SurePetcarePet> pets = new ArrayList<>();
33     public List<SurePetcarePhoto> photos = new ArrayList<>();
34     public List<SurePetcareTag> tags = new ArrayList<>();
35     @Nullable
36     public SurePetcareUser user;
37
38     public @Nullable <T extends SurePetcareBaseObject> T getById(List<T> elements, String id) {
39         for (T e : elements) {
40             if (id.equals(e.id.toString())) {
41                 return e;
42             }
43         }
44         return null;
45     }
46
47     @Override
48     public String toString() {
49         return "SurePetcareTopology [# of Devices=" + devices.size() + ", # of Households=" + households.size()
50                 + ", # of pets=" + pets.size() + "]";
51     }
52 }