]> git.basschouten.com Git - openhab-addons.git/blob
ea6d26c60ffd1e14de3ec4eb2369aa225a7e05f3
[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
17 import com.thoughtworks.xstream.annotations.XStreamAlias;
18 import com.thoughtworks.xstream.annotations.XStreamImplicit;
19
20 /**
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}.
26  * 
27  * @author B. van Wetten - Initial contribution
28  * @author Leo Siepel - finish initial contribution
29  */
30 @XStreamAlias("module")
31 public class Module extends PlugwiseBaseModel implements PlugwiseComparableDate<Module> {
32
33     @SuppressWarnings("unused")
34     @XStreamImplicit(itemFieldName = "service", keyFieldName = "id")
35     private Services services;
36
37     @XStreamAlias("vendor_name")
38     private String vendorName;
39
40     @XStreamAlias("vendor_model")
41     private String vendorModel;
42
43     @XStreamAlias("hardware_version")
44     private String hardwareVersion;
45
46     @XStreamAlias("firmware_version")
47     private String firmwareVersion;
48
49     public String getVendorName() {
50         return vendorName;
51     }
52
53     public String getVendorModel() {
54         return vendorModel;
55     }
56
57     public String getHardwareVersion() {
58         return hardwareVersion;
59     }
60
61     public String getFirmwareVersion() {
62         return firmwareVersion;
63     }
64
65     @Override
66     public int compareDateWith(Module compareTo) {
67         if (compareTo == null) {
68             return -1;
69         }
70         ZonedDateTime compareToDate = compareTo.getModifiedDate();
71         ZonedDateTime compareFromDate = this.getModifiedDate();
72         if (compareFromDate == null) {
73             return -1;
74         } else if (compareToDate == null) {
75             return 1;
76         } else {
77             return compareFromDate.compareTo(compareToDate);
78         }
79     }
80
81     @Override
82     public boolean isNewerThan(Module hasModifiedDate) {
83         return compareDateWith(hasModifiedDate) > 0;
84     }
85
86     @Override
87     public boolean isOlderThan(Module hasModifiedDate) {
88         return compareDateWith(hasModifiedDate) < 0;
89     }
90 }