]> git.basschouten.com Git - openhab-addons.git/blob
09ae2bd4fc2dafdcd48df003303ee06535c52256
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2024 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.dto;
14
15 import java.util.List;
16 import java.util.Optional;
17
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
20 import org.openhab.binding.netatmo.internal.api.ApiResponse;
21 import org.openhab.binding.netatmo.internal.deserialization.NAObjectMap;
22
23 /**
24  * The {@link NAHomeStatus} holds data for a given home.
25  *
26  * @author GaĆ«l L'hopital - Initial contribution
27  *
28  */
29 @NonNullByDefault
30 public class NAHomeStatus {
31     public class NAHomeStatusResponse extends ApiResponse<NAHomeStatus> {
32     }
33
34     public class HomeStatus extends NAThing {
35         private @Nullable NAObjectMap<HomeStatusModule> modules;
36         private @Nullable NAObjectMap<Room> rooms;
37         private @Nullable NAObjectMap<HomeStatusPerson> persons;
38
39         public NAObjectMap<HomeStatusModule> getModules() {
40             NAObjectMap<HomeStatusModule> local = modules;
41             return local != null ? local : new NAObjectMap<>();
42         }
43
44         public NAObjectMap<Room> getRooms() {
45             NAObjectMap<Room> local = rooms;
46             return local != null ? local : new NAObjectMap<>();
47         }
48
49         public NAObjectMap<HomeStatusPerson> getPersons() {
50             NAObjectMap<HomeStatusPerson> local = persons;
51             return local != null ? local : new NAObjectMap<>();
52         }
53     }
54
55     private @Nullable HomeStatus home;
56     private List<NAError> errors = List.of();
57
58     public Optional<HomeStatus> getHomeStatus() {
59         return Optional.ofNullable(home);
60     }
61
62     public List<NAError> getErrors() {
63         return errors;
64     }
65 }