]> git.basschouten.com Git - openhab-addons.git/blob
285b169ce9231bf751bee2fa2bca78e55a7e2246
[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.cache;
14
15 import static org.openhab.binding.unifi.internal.api.cache.UniFiCache.Prefix.DESC;
16 import static org.openhab.binding.unifi.internal.api.cache.UniFiCache.Prefix.ID;
17 import static org.openhab.binding.unifi.internal.api.cache.UniFiCache.Prefix.NAME;
18
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.eclipse.jdt.annotation.Nullable;
21 import org.openhab.binding.unifi.internal.api.dto.UniFiSite;
22
23 /**
24  * The {@link UniFiSiteCache} is a specific implementation of {@link UniFiCache} for the purpose of caching
25  * {@link UniFiSite} instances.
26  *
27  * The cache uses the following prefixes: <code>id</code>, <code>name</code>, <code>desc</code>
28  *
29  * @author Matthew Bowman - Initial contribution
30  */
31 @NonNullByDefault
32 class UniFiSiteCache extends UniFiCache<UniFiSite> {
33
34     public UniFiSiteCache() {
35         super(ID, NAME, DESC);
36     }
37
38     @Override
39     protected @Nullable String getSuffix(final UniFiSite site, final Prefix prefix) {
40         switch (prefix) {
41             case ID:
42                 return site.getId();
43             case NAME:
44                 return site.getName();
45             case DESC:
46                 return site.getDescription();
47             default:
48                 return null;
49         }
50     }
51 }