]> git.basschouten.com Git - openhab-addons.git/blob
faff31332029f00e8dfdbfc7d258f36a0a2f1e4e
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2024 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.emotiva.internal.dto;
14
15 import static org.openhab.binding.emotiva.internal.protocol.EmotivaProtocolVersion.PROTOCOL_V2;
16
17 import java.util.ArrayList;
18 import java.util.List;
19
20 import javax.xml.bind.annotation.XmlAttribute;
21 import javax.xml.bind.annotation.XmlRootElement;
22
23 import org.openhab.binding.emotiva.internal.protocol.EmotivaControlCommands;
24 import org.openhab.binding.emotiva.internal.protocol.EmotivaSubscriptionTags;
25
26 /**
27  * A helper class for sending {@link EmotivaSubscriptionDTO} messages.
28  *
29  * @author Espen Fossen - Initial contribution
30  */
31 @XmlRootElement(name = "emotivaSubscription")
32 public class EmotivaSubscriptionRequest extends AbstractJAXBElementDTO {
33
34     @XmlAttribute
35     private String protocol = PROTOCOL_V2.value();
36
37     @SuppressWarnings("unused")
38     public EmotivaSubscriptionRequest() {
39     }
40
41     public EmotivaSubscriptionRequest(List<EmotivaCommandDTO> commands, String protocol) {
42         this.protocol = protocol;
43         this.commands = commands;
44     }
45
46     public EmotivaSubscriptionRequest(EmotivaSubscriptionTags[] emotivaCommandTypes, String protocol) {
47         this.protocol = protocol;
48         List<EmotivaCommandDTO> list = new ArrayList<>();
49         for (EmotivaSubscriptionTags commandType : emotivaCommandTypes) {
50             list.add(EmotivaCommandDTO.fromTypeWithAck(commandType));
51         }
52         this.commands = list;
53     }
54
55     public EmotivaSubscriptionRequest(EmotivaSubscriptionTags tag) {
56         this.commands = List.of(EmotivaCommandDTO.fromTypeWithAck(tag));
57     }
58
59     public EmotivaSubscriptionRequest(EmotivaControlCommands commandType, String protocol) {
60         this.protocol = protocol;
61         this.commands = List.of(EmotivaCommandDTO.fromTypeWithAck(commandType));
62     }
63 }