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.plugwiseha.internal.api.model.dto;
15 import java.time.ZonedDateTime;
16 import java.util.Optional;
18 import com.thoughtworks.xstream.annotations.XStreamAlias;
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}.
26 * @author B. van Wetten - Initial contribution
27 * @author Leo Siepel - finish initial contribution
29 @XStreamAlias("actuator_functionality")
30 public class ActuatorFunctionality extends PlugwiseBaseModel implements PlugwiseComparableDate<ActuatorFunctionality> {
33 private String duration;
34 private String setpoint;
35 private String resolution;
38 @XStreamAlias("regulation_control")
39 private String regulationControl;
41 @XStreamAlias("cooling_allowed")
42 private String coolingAllowed;
44 @XStreamAlias("preheating_allowed")
45 private String preHeat;
47 @XStreamAlias("lower_bound")
48 private String lowerBound;
50 @XStreamAlias("upper_bound")
51 private String upperBound;
53 @XStreamAlias("updated_date")
54 private ZonedDateTime updatedDate;
56 public String getType() {
60 public String getDuration() {
64 public String getSetpoint() {
68 public String getResolution() {
72 public String getLowerBound() {
76 public String getUpperBound() {
81 public ZonedDateTime getUpdatedDate() {
85 public String getRegulationControl() {
86 return regulationControl;
89 public Optional<String> getCoolingAllowed() {
90 return Optional.ofNullable(coolingAllowed);
93 public Optional<String> getPreHeatState() {
94 return Optional.ofNullable(preHeat);
97 public Optional<String> getRelayLockState() {
98 return Optional.ofNullable(lock);
102 public int compareDateWith(ActuatorFunctionality compareTo) {
103 if (compareTo == null) {
106 ZonedDateTime compareToDate = compareTo.getModifiedDate();
107 ZonedDateTime compareFromDate = this.getModifiedDate();
108 if (compareFromDate == null) {
110 } else if (compareToDate == null) {
113 return compareFromDate.compareTo(compareToDate);
118 public boolean isNewerThan(ActuatorFunctionality hasModifiedDate) {
119 return compareDateWith(hasModifiedDate) > 0;
123 public boolean isOlderThan(ActuatorFunctionality hasModifiedDate) {
124 return compareDateWith(hasModifiedDate) < 0;