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