]> git.basschouten.com Git - openhab-addons.git/blob
6e32fbdc880d9b648a421ab0104db38617b827d8
[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.hue.internal.api.dto.clip1;
14
15 import static java.util.stream.Collectors.joining;
16
17 import java.util.ArrayList;
18
19 /**
20  * Collection of updates
21  *
22  * @author Q42 - Initial contribution
23  * @author Denis Dudnik - moved Jue library source code inside the smarthome Hue binding, minor code cleanup
24  * @author Samuel Leisering - Added support for sensor API
25  * @author Christoph Weitkamp - Added support for sensor API
26  */
27 public class ConfigUpdate {
28
29     public final ArrayList<Command> commands = new ArrayList<>();
30
31     public ConfigUpdate() {
32         super();
33     }
34
35     public boolean isEmpty() {
36         return commands.isEmpty();
37     }
38
39     public String toJson() {
40         return commands.stream().map(c -> c.toJson()).collect(joining(",", "{", "}"));
41     }
42
43     /**
44      * Returns the message delay recommended by Philips
45      * Regarding to this article: https://developers.meethue.com/documentation/hue-system-performance
46      */
47     public long getMessageDelay() {
48         return commands.size() * 40L;
49     }
50 }