2 * Copyright (c) 2010-2021 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 ParameterizedCommand of the type given in parameter and for the given zone.
44 public static SimpleCommand getIpControlCommand(SimpleCommandType command, int zone) {
45 SimpleCommand result = new SimpleCommand(command, zone);
50 * Return a ParameterizedCommand of the type given in parameter. The
51 * parameter of the command has to be set before send.
57 public static ParameterizedCommand getIpControlCommand(ParameterizedCommandType command, int zone) {
58 ParameterizedCommand result = new ParameterizedCommand(command, zone);
63 * Return a ParameterizedCommand of the type given in parameter. The
64 * parameter of the command is set with the given paramter value.
71 public static ParameterizedCommand getIpControlCommand(ParameterizedCommandType command, String parameter,
73 ParameterizedCommand result = getIpControlCommand(command, zone);
74 result.setParameter(parameter);
79 * Return a IpControlResponse object based on the given response data.
84 public static Response getIpControlResponse(String responseData) {
85 return new Response(responseData);