]> git.basschouten.com Git - openhab-addons.git/blob
ab4013be5fbd736e242a5a4ba4c6a68cd7dffcb4
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 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("preheating_allowed")
39     private String preHeat;
40
41     @XStreamAlias("lower_bound")
42     private String lowerBound;
43
44     @XStreamAlias("upper_bound")
45     private String upperBound;
46
47     @XStreamAlias("updated_date")
48     private ZonedDateTime updatedDate;
49
50     public String getType() {
51         return type;
52     }
53
54     public String getDuration() {
55         return duration;
56     }
57
58     public String getSetpoint() {
59         return setpoint;
60     }
61
62     public String getResolution() {
63         return resolution;
64     }
65
66     public String getLowerBound() {
67         return lowerBound;
68     }
69
70     public String getUpperBound() {
71         return upperBound;
72     }
73
74     public ZonedDateTime getUpdatedDate() {
75         return updatedDate;
76     }
77
78     public Optional<String> getPreHeatState() {
79         return Optional.ofNullable(preHeat);
80     }
81
82     public Optional<String> getRelayLockState() {
83         return Optional.ofNullable(lock);
84     }
85
86     @Override
87     public int compareDateWith(ActuatorFunctionality compareTo) {
88         if (compareTo == null) {
89             return -1;
90         }
91         ZonedDateTime compareToDate = compareTo.getModifiedDate();
92         ZonedDateTime compareFromDate = this.getModifiedDate();
93         if (compareFromDate == null) {
94             return -1;
95         } else if (compareToDate == null) {
96             return 1;
97         } else {
98             return compareFromDate.compareTo(compareToDate);
99         }
100     }
101
102     @Override
103     public boolean isNewerThan(ActuatorFunctionality hasModifiedDate) {
104         return compareDateWith(hasModifiedDate) > 0;
105     }
106
107     @Override
108     public boolean isOlderThan(ActuatorFunctionality hasModifiedDate) {
109         return compareDateWith(hasModifiedDate) < 0;
110     }
111 }