]> git.basschouten.com Git - openhab-addons.git/blob
eaa07548fe0c69640c6ea4609d2cc9831300a10c
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 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 org.openhab.binding.unifi.internal.api.model.UniFiClient;
16
17 /**
18  * The {@link UniFiClientCache} is a specific implementation of {@link UniFiCache} for the purpose of caching
19  * {@link UniFiClient} instances.
20  *
21  * The cache uses the following prefixes: <code>mac</code>, <code>ip</code>, <code>hostname</code>, and
22  * <code>alias</code>
23  *
24  * @author Matthew Bowman - Initial contribution
25  */
26 public class UniFiClientCache extends UniFiCache<UniFiClient> {
27
28     public UniFiClientCache() {
29         super(PREFIX_ID, PREFIX_MAC, PREFIX_IP, PREFIX_HOSTNAME, PREFIX_ALIAS);
30     }
31
32     @Override
33     protected String getSuffix(UniFiClient client, String prefix) {
34         switch (prefix) {
35             case PREFIX_ID:
36                 return client.getId();
37             case PREFIX_MAC:
38                 return client.getMac();
39             case PREFIX_IP:
40                 return client.getIp();
41             case PREFIX_HOSTNAME:
42                 return client.getHostname();
43             case PREFIX_ALIAS:
44                 return client.getAlias();
45         }
46         return null;
47     }
48 }