]> git.basschouten.com Git - openhab-addons.git/blob
9dd6d7eff8aa402561ca1a1fdae912dac6d41466
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2020 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.lutron.internal.radiora.protocol;
14
15 import java.util.List;
16
17 /**
18  * Abstract base class for commands.
19  *
20  * @author Jeff Lauterbach - Initial Contribution
21  *
22  */
23 public abstract class RadioRACommand {
24
25     protected static final String FIELD_SEPARATOR = ",";
26     protected static final String CMD_TERMINATOR = "\r";
27
28     public abstract String getCommand();
29
30     public abstract List<String> getArgs();
31
32     @Override
33     public String toString() {
34         StringBuilder str = new StringBuilder();
35
36         str.append(getCommand());
37
38         for (String arg : getArgs()) {
39             str.append(FIELD_SEPARATOR);
40             str.append(arg);
41         }
42
43         str.append(CMD_TERMINATOR);
44
45         return str.toString();
46     }
47 }