]> git.basschouten.com Git - openhab-addons.git/blob
9eb04a656eb1b3345b01c079551382c9a257650b
[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.unifi.internal.api.dto;
14
15 import org.openhab.binding.unifi.internal.api.cache.UniFiControllerCache;
16
17 import com.google.gson.annotations.SerializedName;
18
19 /**
20  * The {@link UniFiSite} represents the data model of a UniFi site.
21  *
22  * @author Matthew Bowman - Initial contribution
23  */
24 public class UniFiSite implements HasId {
25
26     private final transient UniFiControllerCache cache;
27
28     public UniFiSite(final UniFiControllerCache cache) {
29         this.cache = cache;
30     }
31
32     @SerializedName("_id")
33     private String id;
34
35     private String name;
36
37     private String desc;
38
39     @Override
40     public String getId() {
41         return id;
42     }
43
44     public String getName() {
45         return name;
46     }
47
48     public String getDescription() {
49         return desc;
50     }
51
52     public UniFiControllerCache getCache() {
53         return cache;
54     }
55
56     public boolean isSite(final UniFiSite site) {
57         return site != null && id.equals(site.getId());
58     }
59
60     public boolean matchesName(final String siteName) {
61         return siteName.equalsIgnoreCase(desc) || siteName.equalsIgnoreCase(name) || siteName.equalsIgnoreCase(id);
62     }
63
64     @Override
65     public String toString() {
66         return String.format("UniFiSite{id: '%s', name: '%s', desc: '%s'}", id, name, desc);
67     }
68 }