2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.lutron.internal.protocol.leap.dto;
15 import java.util.LinkedList;
16 import java.util.List;
17 import java.util.regex.Pattern;
19 import org.openhab.binding.lutron.internal.protocol.leap.AbstractMessageBody;
21 import com.google.gson.annotations.SerializedName;
24 * LEAP ButtonGroup Object
26 * @author Bob Adair - Initial contribution
28 public class ButtonGroup extends AbstractMessageBody {
29 public static final Pattern BUTTONGROUP_HREF_PATTERN = Pattern.compile("/buttongroup/([0-9]+)");
30 public static final Pattern BUTTON_HREF_PATTERN = Pattern.compile("/button/([0-9]+)");
32 @SerializedName("href")
34 @SerializedName("Parent") // device href
35 public Href parent = new Href();
36 @SerializedName("Buttons")
37 public Href[] buttons;
38 @SerializedName("AffectedZones")
39 public AffectedZone[] affectedZones;
40 @SerializedName("SortOrder")
41 public Integer sortOrder;
42 @SerializedName("StopIfMoving")
43 public String stopIfMoving; // Enabled or Disabled
44 @SerializedName("ProgrammingType")
45 public String programmingType; // Column
47 public ButtonGroup() {
50 public int getButtonGroup() {
51 return hrefNumber(BUTTONGROUP_HREF_PATTERN, href);
54 public int getParentDevice() {
55 if (parent != null && parent.href != null) {
56 return hrefNumber(Device.DEVICE_HREF_PATTERN, parent.href);
62 public List<Integer> getButtonList() {
63 LinkedList<Integer> buttonNumList = new LinkedList<>();
64 for (Href button : buttons) {
65 int buttonNum = hrefNumber(BUTTON_HREF_PATTERN, button.href);
66 buttonNumList.add(buttonNum);