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.pioneeravr.internal.protocol;
15 import org.openhab.binding.pioneeravr.internal.protocol.ParameterizedCommand.ParameterizedCommandType;
16 import org.openhab.binding.pioneeravr.internal.protocol.SimpleCommand.SimpleCommandType;
17 import org.openhab.binding.pioneeravr.internal.protocol.ip.IpAvrConnection;
20 * Factory that allows to build IpControl commands/responses.
22 * @author Antoine Besnard - Initial contribution
24 public final class RequestResponseFactory {
27 * Return a connection to the AVR with the given host and port.
33 public static IpAvrConnection getConnection(String host, Integer port) {
34 return new IpAvrConnection(host, port);
38 * Return a SimpleCommand of the type given in parameter.
43 public static SimpleCommand getIpControlCommand(SimpleCommandType command) {
44 return new SimpleCommand(command);
48 * Return a ParameterizedCommand of the type given in parameter and for the given zone.
54 public static SimpleCommand getIpControlCommand(SimpleCommandType command, int zone) {
55 return new SimpleCommand(command, zone);
59 * Return a ParameterizedCommand of the type given in parameter. The
60 * parameter of the command has to be set before send.
65 public static ParameterizedCommand getIpControlCommand(ParameterizedCommandType command) {
66 return new ParameterizedCommand(command);
70 * Return a ParameterizedCommand of the type given in parameter. The
71 * parameter of the command has to be set before send.
77 public static ParameterizedCommand getIpControlCommand(ParameterizedCommandType command, int zone) {
78 return new ParameterizedCommand(command, zone);
82 * Return a ParameterizedCommand of the type given in parameter. The
83 * parameter of the command is set with the given parameter value.
90 public static ParameterizedCommand getIpControlCommand(ParameterizedCommandType command, String parameter) {
91 ParameterizedCommand result = getIpControlCommand(command);
92 result.setParameter(parameter);
97 * Return a ParameterizedCommand of the type given in parameter. The
98 * parameter of the command is set with the given parameter value.
105 public static ParameterizedCommand getIpControlCommand(ParameterizedCommandType command, String parameter,
107 ParameterizedCommand result = getIpControlCommand(command, zone);
108 result.setParameter(parameter);
113 * Return an IpControlResponse object based on the given response data.
115 * @param responseData
118 public static Response getIpControlResponse(String responseData) {
119 return new Response(responseData);