]> git.basschouten.com Git - openhab-addons.git/blob
24a3e15b8b006a5da740aa8d09a78ae3ce9604a8
[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.plugwiseha.internal.api.model.dto;
14
15 import java.time.ZonedDateTime;
16 import java.util.Optional;
17
18 import com.thoughtworks.xstream.annotations.XStreamAlias;
19
20 /**
21  * The {@link ActuatorFunctionality} class is an object model class that mirrors
22  * the XML structure provided by the Plugwise Home Automation controller for the
23  * any actuator functionality. It implements the {@link PlugwiseComparableDate}
24  * interface and extends the abstract class {@link PlugwiseBaseModel}.
25  * 
26  * @author B. van Wetten - Initial contribution
27  * @author Leo Siepel - finish initial contribution
28  */
29 @XStreamAlias("actuator_functionality")
30 public class ActuatorFunctionality extends PlugwiseBaseModel implements PlugwiseComparableDate<ActuatorFunctionality> {
31
32     private String type;
33     private String duration;
34     private String setpoint;
35     private String resolution;
36     private String lock;
37
38     @XStreamAlias("regulation_control")
39     private String regulationControl;
40
41     @XStreamAlias("cooling_allowed")
42     private String coolingAllowed;
43
44     @XStreamAlias("preheating_allowed")
45     private String preHeat;
46
47     @XStreamAlias("lower_bound")
48     private String lowerBound;
49
50     @XStreamAlias("upper_bound")
51     private String upperBound;
52
53     @XStreamAlias("updated_date")
54     private ZonedDateTime updatedDate;
55
56     public String getType() {
57         return type;
58     }
59
60     public String getDuration() {
61         return duration;
62     }
63
64     public String getSetpoint() {
65         return setpoint;
66     }
67
68     public String getResolution() {
69         return resolution;
70     }
71
72     public String getLowerBound() {
73         return lowerBound;
74     }
75
76     public String getUpperBound() {
77         return upperBound;
78     }
79
80     @Override
81     public ZonedDateTime getUpdatedDate() {
82         return updatedDate;
83     }
84
85     public String getRegulationControl() {
86         return regulationControl;
87     }
88
89     public Optional<String> getCoolingAllowed() {
90         return Optional.ofNullable(coolingAllowed);
91     }
92
93     public Optional<String> getPreHeatState() {
94         return Optional.ofNullable(preHeat);
95     }
96
97     public Optional<String> getRelayLockState() {
98         return Optional.ofNullable(lock);
99     }
100
101     @Override
102     public int compareDateWith(ActuatorFunctionality compareTo) {
103         if (compareTo == null) {
104             return -1;
105         }
106         ZonedDateTime compareToDate = compareTo.getModifiedDate();
107         ZonedDateTime compareFromDate = this.getModifiedDate();
108         if (compareFromDate == null) {
109             return -1;
110         } else if (compareToDate == null) {
111             return 1;
112         } else {
113             return compareFromDate.compareTo(compareToDate);
114         }
115     }
116
117     @Override
118     public boolean isNewerThan(ActuatorFunctionality hasModifiedDate) {
119         return compareDateWith(hasModifiedDate) > 0;
120     }
121
122     @Override
123     public boolean isOlderThan(ActuatorFunctionality hasModifiedDate) {
124         return compareDateWith(hasModifiedDate) < 0;
125     }
126 }