]> git.basschouten.com Git - openhab-addons.git/blob
6a60c6fc37a90de399220af1c528d4014bf7d302
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 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.yamahareceiver.internal.protocol.xml;
14
15 /**
16  * Template for XML commands
17  *
18  * @author Tomasz Maruszak - Initial contribution
19  */
20 class CommandTemplate {
21
22     private final String command;
23     private final String path;
24
25     public CommandTemplate(String command, String path) {
26         this.command = command;
27         this.path = path;
28     }
29
30     public CommandTemplate(String command) {
31         this(command, "");
32     }
33
34     public CommandTemplate replace(String oldToken, String newToken) {
35         return new CommandTemplate(command.replace(oldToken, newToken), path.replace(oldToken, newToken));
36     }
37
38     public String apply(Object... args) {
39         return String.format(command, args);
40     }
41
42     public String getPath() {
43         return path;
44     }
45
46     @Override
47     public String toString() {
48         return command;
49     }
50 }