]> git.basschouten.com Git - openhab-addons.git/blob
b950bc36fa21741fa0e94fc083d04afa15889279
[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.elerotransmitterstick.internal.stick;
14
15 import java.util.Arrays;
16 import java.util.concurrent.Delayed;
17 import java.util.concurrent.TimeUnit;
18
19 /**
20  * @author Volker Bier - Initial contribution
21  */
22 public class Command implements Delayed {
23     public static final int TIMED_PRIORITY = 30;
24     public static final int COMMAND_PRIORITY = 20;
25     public static final int FAST_INFO_PRIORITY = 10;
26     public static final int INFO_PRIORITY = 0;
27
28     private Integer[] channelId;
29     private CommandType commandType;
30
31     protected int priority = COMMAND_PRIORITY;
32
33     public Command(final CommandType cmd, final Integer... channels) {
34         channelId = channels;
35         commandType = cmd;
36     }
37
38     protected Command(final CommandType cmd, int priority, final Integer... channels) {
39         this(cmd, channels);
40
41         this.priority = priority;
42     }
43
44     @Override
45     public String toString() {
46         return "Command " + commandType + " on channels " + Arrays.toString(channelId) + " with priority " + priority;
47     }
48
49     @Override
50     @SuppressWarnings("PMD.CompareObjectsWithEquals")
51     public int compareTo(Delayed delayed) {
52         if (delayed == this) {
53             return 0;
54         }
55
56         return Long.compare(0, delayed.getDelay(TimeUnit.MILLISECONDS));
57     }
58
59     @Override
60     public long getDelay(TimeUnit unit) {
61         return 0;
62     }
63
64     public int getPriority() {
65         return priority;
66     }
67
68     public Integer[] getChannelIds() {
69         return channelId;
70     }
71
72     public CommandType getCommandType() {
73         return commandType;
74     }
75 }