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;
17 import com.thoughtworks.xstream.annotations.XStreamAlias;
18 import com.thoughtworks.xstream.annotations.XStreamImplicit;
21 * The {@link Module} class is an object model class that
22 * mirrors the XML structure provided by the Plugwise Home Automation
23 * controller for a Plugwise module.
24 * It implements the {@link PlugwiseComparableDate} interface and
25 * extends the abstract class {@link PlugwiseBaseModel}.
27 * @author B. van Wetten - Initial contribution
28 * @author Leo Siepel - finish initial contribution
30 @XStreamAlias("module")
31 public class Module extends PlugwiseBaseModel implements PlugwiseComparableDate<Module> {
33 @SuppressWarnings("unused")
34 @XStreamImplicit(itemFieldName = "service", keyFieldName = "id")
35 private Services services;
37 @XStreamAlias("vendor_name")
38 private String vendorName;
40 @XStreamAlias("vendor_model")
41 private String vendorModel;
43 @XStreamAlias("hardware_version")
44 private String hardwareVersion;
46 @XStreamAlias("firmware_version")
47 private String firmwareVersion;
49 public String getVendorName() {
53 public String getVendorModel() {
57 public String getHardwareVersion() {
58 return hardwareVersion;
61 public String getFirmwareVersion() {
62 return firmwareVersion;
66 public int compareDateWith(Module compareTo) {
67 if (compareTo == null) {
70 ZonedDateTime compareToDate = compareTo.getModifiedDate();
71 ZonedDateTime compareFromDate = this.getModifiedDate();
72 if (compareFromDate == null) {
74 } else if (compareToDate == null) {
77 return compareFromDate.compareTo(compareToDate);
82 public boolean isNewerThan(Module hasModifiedDate) {
83 return compareDateWith(hasModifiedDate) > 0;
87 public boolean isOlderThan(Module hasModifiedDate) {
88 return compareDateWith(hasModifiedDate) < 0;