]> git.basschouten.com Git - openhab-addons.git/blob
f68b6d8ec9e61ee8017886ed064e725f1965b2f6
[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.lutron.internal.protocol.leap.dto;
14
15 import java.util.regex.Pattern;
16
17 import org.openhab.binding.lutron.internal.protocol.leap.AbstractMessageBody;
18
19 import com.google.gson.annotations.SerializedName;
20
21 /**
22  * LEAP Project Object
23  *
24  * @author Peter Wojciechowski - Initial contribution
25  */
26 public class Project extends AbstractMessageBody {
27     @SerializedName("href")
28     public String href;
29
30     @SerializedName("Name")
31     public String name;
32
33     @SerializedName("ProductType")
34     public String productType;
35
36     @SerializedName("MasterDeviceList")
37     public MasterDeviceList masterDeviceList;
38
39     @SerializedName("Contacts")
40     public Href[] contacts;
41
42     @SerializedName("TimeclockEventRules")
43     public Href timeclockEventRules;
44
45     @SerializedName("ProjectModifiedTimestamp")
46     public ProjectTimestamp projectModifiedTimestamp;
47
48     public class MasterDeviceList {
49         public static final Pattern DEVICE_HREF_PATTERN = Pattern.compile("/device/([0-9]+)");
50
51         public int getDeviceIdFromHref(int deviceIndex) {
52             if (devices.length == 0) {
53                 return 0;
54             }
55
56             return hrefNumber(DEVICE_HREF_PATTERN, devices[deviceIndex].href);
57         }
58
59         @SerializedName("Devices")
60         public Href[] devices;
61     }
62 }