2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.unifi.internal.api.dto;
15 import org.openhab.binding.unifi.internal.api.cache.UniFiControllerCache;
17 import com.google.gson.annotations.SerializedName;
20 * The {@link UniFiSite} represents the data model of a UniFi site.
22 * @author Matthew Bowman - Initial contribution
23 * @author Mark Herwege - Added guest vouchers
25 public class UniFiSite implements HasId {
27 private final transient UniFiControllerCache cache;
29 public UniFiSite(final UniFiControllerCache cache) {
33 @SerializedName("_id")
41 public String getId() {
45 public String getName() {
49 public String getDescription() {
53 public UniFiControllerCache getCache() {
57 public String getVoucher() {
58 UniFiVoucher voucher = cache.getVoucher(this);
59 if (voucher == null) {
62 return voucher.getCode();
65 public boolean isSite(final UniFiSite site) {
66 return site != null && id.equals(site.getId());
69 public boolean matchesName(final String siteName) {
70 return siteName.equalsIgnoreCase(desc) || siteName.equalsIgnoreCase(name) || siteName.equalsIgnoreCase(id);
74 public String toString() {
75 return String.format("UniFiSite{id: '%s', name: '%s', desc: '%s'}", id, name, desc);