]> git.basschouten.com Git - openhab-addons.git/blob
6db44d40cf8fd719ea947aee148be7edfe5b0ccf
[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.ALIAS;
16 import static org.openhab.binding.unifi.internal.api.cache.UniFiCache.Prefix.HOSTNAME;
17 import static org.openhab.binding.unifi.internal.api.cache.UniFiCache.Prefix.ID;
18 import static org.openhab.binding.unifi.internal.api.cache.UniFiCache.Prefix.IP;
19 import static org.openhab.binding.unifi.internal.api.cache.UniFiCache.Prefix.MAC;
20
21 import org.eclipse.jdt.annotation.NonNullByDefault;
22 import org.eclipse.jdt.annotation.Nullable;
23 import org.openhab.binding.unifi.internal.api.dto.UniFiClient;
24
25 /**
26  * The {@link UniFiClientCache} is a specific implementation of {@link UniFiCache} for the purpose of caching
27  * {@link UniFiClient} instances.
28  *
29  * The cache uses the following prefixes: <code>mac</code>, <code>ip</code>, <code>hostname</code>, and
30  * <code>alias</code>
31  *
32  * @author Matthew Bowman - Initial contribution
33  */
34 @NonNullByDefault
35 class UniFiClientCache extends UniFiCache<UniFiClient> {
36
37     public UniFiClientCache() {
38         super(ID, MAC, IP, HOSTNAME, ALIAS);
39     }
40
41     @Override
42     protected @Nullable String getSuffix(final UniFiClient client, final Prefix prefix) {
43         switch (prefix) {
44             case ID:
45                 return client.getId();
46             case MAC:
47                 return client.getMac();
48             case IP:
49                 return client.getIp();
50             case HOSTNAME:
51                 return client.getHostname();
52             case ALIAS:
53                 return client.getAlias();
54             default:
55                 return null;
56         }
57     }
58 }