]> git.basschouten.com Git - openhab-addons.git/blob
b004a6bb7802abfdeb4e62ac77ca4709a205964b
[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.plugwiseha.internal.api.model.dto;
14
15 import java.util.Map;
16
17 /**
18  * The {@link Locations} class is an object model class that mirrors the XML
19  * structure provided by the Plugwise Home Automation controller for the
20  * collection of Plugwise locations/zones. It extends the
21  * {@link PlugwiseHACollection} class.
22  * 
23  * @author B. van Wetten - Initial contribution
24  */
25 public class Locations extends PlugwiseHACollection<Location> {
26
27     @Override
28     public void merge(Map<String, Location> locations) {
29         if (locations != null) {
30             for (Location location : locations.values()) {
31                 String id = location.getId();
32                 Location originalLocation = this.get(id);
33
34                 Boolean originalLocationIsOlder = false;
35                 if (originalLocation != null) {
36                     originalLocationIsOlder = originalLocation.isOlderThan(location);
37                 }
38
39                 if (originalLocation != null && originalLocationIsOlder) {
40                     Logs updatedPointLogs = location.getPointLogs();
41                     if (updatedPointLogs != null) {
42                         updatedPointLogs.merge(originalLocation.getPointLogs());
43                     }
44
45                     ActuatorFunctionalities updatedActuatorFunctionalities = location.getActuatorFunctionalities();
46                     if (updatedActuatorFunctionalities != null) {
47                         updatedActuatorFunctionalities.merge(originalLocation.getActuatorFunctionalities());
48                     }
49
50                     this.put(id, location);
51                 }
52             }
53         }
54     }
55 }