]> git.basschouten.com Git - openhab-addons.git/blob
8d211e75ab3f687055828f73bb7d7abae36929c7
[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.vesync.internal.handlers;
14
15 import java.util.List;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18
19 /**
20  * The {@link VeSyncDeviceMetadata} class contains the definition for the identification of multiple device types,
21  * to a single family of devices.
22  *
23  * New Device Type Ids are formatted as [DeviceType][-][Device Generation][-][Device Region]
24  *
25  * @author David Goodyear - Initial contribution
26  */
27 @NonNullByDefault
28 public class VeSyncDeviceMetadata {
29
30     public VeSyncDeviceMetadata(final String deviceFamilyName, final List<String> deviceGenerations,
31             final List<String> nonStandardIds) {
32         this.deviceFamilyName = deviceFamilyName;
33         this.deviceGenerations = deviceGenerations;
34         this.nonStandardIds = nonStandardIds;
35     }
36
37     /**
38      * The name of the family the set of ID's represents.
39      *
40      */
41     public final String deviceFamilyName;
42
43     /**
44      * The version id, that represents the specific model of the device
45      */
46     public final List<String> deviceGenerations;
47
48     /**
49      * Device Types not following the standard 3 segment convention
50      */
51     public final List<String> nonStandardIds;
52
53     public boolean deviceTypeIdMatches(final String deviceType, final String[] deviceTypeSegments) {
54         if (nonStandardIds.contains(deviceType)) {
55             return true;
56         }
57         if (deviceTypeSegments.length == 3) {
58             return deviceGenerations.contains(deviceTypeSegments[1]);
59         }
60         return false;
61     }
62
63     public String getDeviceFamilyName() {
64         return deviceFamilyName;
65     }
66 }