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 SimpleCommand result = new SimpleCommand(command);
49 * Return a ParameterizedCommand of the type given in parameter and for the given zone.
55 public static SimpleCommand getIpControlCommand(SimpleCommandType command, int zone) {
56 SimpleCommand result = new SimpleCommand(command, zone);
61 * Return a ParameterizedCommand of the type given in parameter. The
62 * parameter of the command has to be set before send.
67 public static ParameterizedCommand getIpControlCommand(ParameterizedCommandType command) {
68 ParameterizedCommand result = new ParameterizedCommand(command);
73 * Return a ParameterizedCommand of the type given in parameter. The
74 * parameter of the command has to be set before send.
80 public static ParameterizedCommand getIpControlCommand(ParameterizedCommandType command, int zone) {
81 ParameterizedCommand result = new ParameterizedCommand(command, zone);
86 * Return a ParameterizedCommand of the type given in parameter. The
87 * parameter of the command is set with the given parameter value.
94 public static ParameterizedCommand getIpControlCommand(ParameterizedCommandType command, String parameter) {
95 ParameterizedCommand result = getIpControlCommand(command);
96 result.setParameter(parameter);
101 * Return a ParameterizedCommand of the type given in parameter. The
102 * parameter of the command is set with the given parameter value.
109 public static ParameterizedCommand getIpControlCommand(ParameterizedCommandType command, String parameter,
111 ParameterizedCommand result = getIpControlCommand(command, zone);
112 result.setParameter(parameter);
117 * Return an IpControlResponse object based on the given response data.
119 * @param responseData
122 public static Response getIpControlResponse(String responseData) {
123 return new Response(responseData);