2 * Copyright (c) 2010-2022 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("preheating_allowed")
39 private String preHeat;
41 @XStreamAlias("lower_bound")
42 private String lowerBound;
44 @XStreamAlias("upper_bound")
45 private String upperBound;
47 @XStreamAlias("updated_date")
48 private ZonedDateTime updatedDate;
50 public String getType() {
54 public String getDuration() {
58 public String getSetpoint() {
62 public String getResolution() {
66 public String getLowerBound() {
70 public String getUpperBound() {
74 public ZonedDateTime getUpdatedDate() {
78 public Optional<String> getPreHeatState() {
79 return Optional.ofNullable(preHeat);
82 public Optional<String> getRelayLockState() {
83 return Optional.ofNullable(lock);
87 public int compareDateWith(ActuatorFunctionality compareTo) {
88 if (compareTo == null) {
91 ZonedDateTime compareToDate = compareTo.getModifiedDate();
92 ZonedDateTime compareFromDate = this.getModifiedDate();
93 if (compareFromDate == null) {
95 } else if (compareToDate == null) {
98 return compareFromDate.compareTo(compareToDate);
103 public boolean isNewerThan(ActuatorFunctionality hasModifiedDate) {
104 return compareDateWith(hasModifiedDate) > 0;
108 public boolean isOlderThan(ActuatorFunctionality hasModifiedDate) {
109 return compareDateWith(hasModifiedDate) < 0;