]> git.basschouten.com Git - openhab-addons.git/blob
5eb458f2d744fea751a9e0bdb0fde26c2a9d5b92
[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 heat set point API requests
17  *
18  * @author Jasper van Zuijlen - Initial contribution
19  *
20  */
21 public class HeatSetPointBuilder implements RequestBuilder<HeatSetPoint> {
22
23     private double setPoint;
24     private boolean hasSetPoint;
25     private boolean cancelSetPoint;
26
27     /**
28      * Creates a new heat set point command
29      *
30      * @return A heat set point command or null when the configuration is invalid
31      *
32      */
33     @Override
34     public HeatSetPoint build() {
35         if (cancelSetPoint) {
36             return new HeatSetPoint();
37         }
38         if (hasSetPoint) {
39             return new HeatSetPoint(setPoint);
40         }
41         return null;
42     }
43
44     public HeatSetPointBuilder setSetPoint(double setPoint) {
45         this.hasSetPoint = true;
46         this.setPoint = setPoint;
47         return this;
48     }
49
50     public HeatSetPointBuilder setCancelSetPoint() {
51         cancelSetPoint = true;
52         return this;
53     }
54 }