]> git.basschouten.com Git - openhab-addons.git/blob
951e21ed36bad3225724c33878e65328d56929ca
[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.lametrictime.internal.api.dto;
14
15 import java.util.SortedMap;
16 import java.util.TreeMap;
17
18 import org.openhab.binding.lametrictime.internal.api.local.dto.BooleanParameter;
19 import org.openhab.binding.lametrictime.internal.api.local.dto.IntegerParameter;
20 import org.openhab.binding.lametrictime.internal.api.local.dto.Parameter;
21 import org.openhab.binding.lametrictime.internal.api.local.dto.UpdateAction;
22
23 /**
24  * Implementation class for the CountdownApp.
25  *
26  * @author Gregory Moyer - Initial contribution
27  */
28 public class CountdownApp extends CoreApplication {
29     private static final String NAME = "com.lametric.countdown";
30
31     private static final String ACTION_CONFIGURE = "countdown.configure";
32     private static final String ACTION_PAUSE = "countdown.pause";
33     private static final String ACTION_RESET = "countdown.reset";
34     private static final String ACTION_START = "countdown.start";
35
36     private static final String PARAMETER_DURATION = "duration";
37     private static final String PARAMETER_START_NOW = "start_now";
38
39     public CountdownApp() {
40         super(NAME);
41     }
42
43     public CoreAction configure(int duration, boolean startNow) {
44         SortedMap<String, Parameter> parameters = new TreeMap<>();
45         parameters.put(PARAMETER_DURATION, new IntegerParameter().withValue(duration));
46         parameters.put(PARAMETER_START_NOW, new BooleanParameter().withValue(startNow));
47
48         return new CoreAction(this, new UpdateAction().withId(ACTION_CONFIGURE).withParameters(parameters));
49     }
50
51     public CoreAction pause() {
52         return new CoreAction(this, new UpdateAction().withId(ACTION_PAUSE));
53     }
54
55     public CoreAction reset() {
56         return new CoreAction(this, new UpdateAction().withId(ACTION_RESET));
57     }
58
59     public CoreAction start() {
60         return new CoreAction(this, new UpdateAction().withId(ACTION_START));
61     }
62 }