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() {
80 public ZonedDateTime getUpdatedDate() {
84 public String getRegulationControl() {
85 return regulationControl;
88 public Optional<String> getCoolingAllowed() {
89 return Optional.ofNullable(coolingAllowed);
92 public Optional<String> getPreHeatState() {
93 return Optional.ofNullable(preHeat);
96 public Optional<String> getRelayLockState() {
97 return Optional.ofNullable(lock);
101 public int compareDateWith(ActuatorFunctionality compareTo) {
102 if (compareTo == null) {
105 ZonedDateTime compareToDate = compareTo.getModifiedDate();
106 ZonedDateTime compareFromDate = this.getModifiedDate();
107 if (compareFromDate == null) {
109 } else if (compareToDate == null) {
112 return compareFromDate.compareTo(compareToDate);
117 public boolean isNewerThan(ActuatorFunctionality hasModifiedDate) {
118 return compareDateWith(hasModifiedDate) > 0;
122 public boolean isOlderThan(ActuatorFunctionality hasModifiedDate) {
123 return compareDateWith(hasModifiedDate) < 0;