2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.lametrictime.internal.api.dto;
15 import java.util.SortedMap;
16 import java.util.TreeMap;
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;
24 * Implementation class for the CountdownApp.
26 * @author Gregory Moyer - Initial contribution
28 public class CountdownApp extends CoreApplication {
29 private static final String NAME = "com.lametric.countdown";
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";
36 private static final String PARAMETER_DURATION = "duration";
37 private static final String PARAMETER_START_NOW = "start_now";
39 public CountdownApp() {
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));
48 return new CoreAction(this, new UpdateAction().withId(ACTION_CONFIGURE).withParameters(parameters));
51 public CoreAction pause() {
52 return new CoreAction(this, new UpdateAction().withId(ACTION_PAUSE));
55 public CoreAction reset() {
56 return new CoreAction(this, new UpdateAction().withId(ACTION_RESET));
59 public CoreAction start() {
60 return new CoreAction(this, new UpdateAction().withId(ACTION_START));