]> git.basschouten.com Git - openhab-addons.git/blob
44f583996fc23107e7402bf5f85bd7758743c55c
[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.loxone.internal.types;
14
15 import java.util.HashSet;
16 import java.util.Set;
17
18 import org.openhab.binding.loxone.internal.controls.LxControl;
19
20 /**
21  * Container on Loxone Miniserver that groups {@link LxControl} objects.
22  * <p>
23  * Examples of containers are rooms and categories.
24  *
25  * @author Pawel Pieczul - initial contribution
26  *
27  */
28 public class LxContainer {
29     private LxUuid uuid; // set by JSON deserialization
30     private String name; // set by JSON deserialization
31     private final Set<LxControl> controls;
32
33     /**
34      * Create a new container with given uuid and name
35      */
36     LxContainer() {
37         controls = new HashSet<>();
38     }
39
40     /**
41      * Obtain container's current name
42      *
43      * @return
44      *         container's current name
45      */
46     public String getName() {
47         return name;
48     }
49
50     /**
51      * Obtain container's UUID (assigned by Loxone Miniserver)
52      *
53      * @return
54      *         container's UUID
55      */
56     public LxUuid getUuid() {
57         return uuid;
58     }
59
60     /**
61      * Add a new control to this container
62      *
63      * @param control control to be added
64      */
65     public void addControl(LxControl control) {
66         controls.add(control);
67     }
68
69     /**
70      * Removes a control from the container
71      *
72      * @param control control object to remove from the container
73      * @return true if control object existed in the container and was removed
74      */
75     public boolean removeControl(LxControl control) {
76         return controls.remove(control);
77     }
78 }