]> git.basschouten.com Git - openhab-addons.git/blob
92bee418c78f335930aae91fcd358e3c34e519ed
[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.evohome.internal.api.models.v2.dto.request;
14
15 /**
16  * Builder for mode API requests
17  *
18  * @author Jasper van Zuijlen - Initial contribution
19  *
20  */
21 public class ModeBuilder extends TimedRequestBuilder<Mode> {
22
23     private String mode;
24     private boolean hasSetMode;
25
26     /**
27      * Creates a new mode command
28      *
29      * @return A mode command or null when the configuration is invalid
30      *
31      */
32     @Override
33     public Mode build() {
34         if (hasSetMode) {
35             if (useEndTime()) {
36                 return new Mode(mode, getYear(), getMonth(), getDay());
37             } else {
38                 return new Mode(mode);
39             }
40         }
41         return null;
42     }
43
44     public ModeBuilder setMode(String mode) {
45         this.hasSetMode = true;
46         this.mode = mode;
47         return this;
48     }
49 }