]> git.basschouten.com Git - openhab-addons.git/blob
48a1684376e7f21cf68dd2a0faa57f93991aa14e
[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.protocol;
14
15 /**
16  * Command to a Lutron integration access point.
17  *
18  * @author Allan Tong - Initial contribution
19  *
20  */
21 public class LutronCommand {
22     private final LutronOperation operation;
23     private final LutronCommandType type;
24     private final int integrationId;
25     private final Object[] parameters;
26
27     public LutronCommand(LutronOperation operation, LutronCommandType type, int integrationId, Object... parameters) {
28         this.operation = operation;
29         this.type = type;
30         this.integrationId = integrationId;
31         this.parameters = parameters;
32     }
33
34     public LutronCommandType getType() {
35         return this.type;
36     }
37
38     public int getIntegrationId() {
39         return this.integrationId;
40     }
41
42     public Object[] getParameters() {
43         return this.parameters;
44     }
45
46     @Override
47     public String toString() {
48         StringBuilder builder = new StringBuilder().append(this.operation).append(this.type);
49
50         if (integrationId >= 0) {
51             builder.append(',').append(this.integrationId);
52         }
53
54         if (parameters != null) {
55             for (Object parameter : parameters) {
56                 builder.append(',').append(parameter);
57             }
58         }
59
60         return builder.toString();
61     }
62 }