2 * Copyright (c) 2010-2024 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.emotiva.internal.dto;
15 import static org.openhab.binding.emotiva.internal.protocol.EmotivaProtocolVersion.PROTOCOL_V2;
17 import java.util.ArrayList;
18 import java.util.List;
20 import javax.xml.bind.annotation.XmlAttribute;
21 import javax.xml.bind.annotation.XmlRootElement;
23 import org.openhab.binding.emotiva.internal.protocol.EmotivaControlCommands;
24 import org.openhab.binding.emotiva.internal.protocol.EmotivaSubscriptionTags;
27 * A helper class for sending {@link EmotivaSubscriptionDTO} messages.
29 * @author Espen Fossen - Initial contribution
31 @XmlRootElement(name = "emotivaSubscription")
32 public class EmotivaSubscriptionRequest extends AbstractJAXBElementDTO {
35 private String protocol = PROTOCOL_V2.value();
37 @SuppressWarnings("unused")
38 public EmotivaSubscriptionRequest() {
41 public EmotivaSubscriptionRequest(List<EmotivaCommandDTO> commands, String protocol) {
42 this.protocol = protocol;
43 this.commands = commands;
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));
55 public EmotivaSubscriptionRequest(EmotivaSubscriptionTags tag) {
56 this.commands = List.of(EmotivaCommandDTO.fromTypeWithAck(tag));
59 public EmotivaSubscriptionRequest(EmotivaControlCommands commandType, String protocol) {
60 this.protocol = protocol;
61 this.commands = List.of(EmotivaCommandDTO.fromTypeWithAck(commandType));