]> git.basschouten.com Git - openhab-addons.git/blob
867e3158ee6dad7333737ec40ead99207f242c38
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 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.avmfritz.internal.dto;
14
15 import javax.xml.bind.annotation.XmlAccessType;
16 import javax.xml.bind.annotation.XmlAccessorType;
17 import javax.xml.bind.annotation.XmlAttribute;
18 import javax.xml.bind.annotation.XmlElement;
19 import javax.xml.bind.annotation.XmlRootElement;
20
21 /**
22  * See {@link DeviceListModel}.
23  *
24  * @author Christoph Weitkamp - Initial contribution
25  */
26 @XmlAccessorType(XmlAccessType.FIELD)
27 @XmlRootElement(name = "button")
28 public class ButtonModel {
29
30     @XmlAttribute(name = "identifier")
31     private String identifier;
32
33     @XmlAttribute(name = "id")
34     private String buttonId;
35
36     @XmlElement(name = "name")
37     private String name;
38
39     @XmlElement(name = "lastpressedtimestamp")
40     private int lastpressedtimestamp;
41
42     public String getName() {
43         return name;
44     }
45
46     public void setName(String name) {
47         this.name = name;
48     }
49
50     public String getIdentifier() {
51         return identifier != null ? identifier.replace(" ", "") : null;
52     }
53
54     public void setIdentifier(String identifier) {
55         this.identifier = identifier;
56     }
57
58     public String getButtonId() {
59         return buttonId;
60     }
61
62     public void setButtonId(String buttonId) {
63         this.buttonId = buttonId;
64     }
65
66     public int getLastpressedtimestamp() {
67         return lastpressedtimestamp;
68     }
69
70     public void setLastpressedtimestamp(int lastpressedtimestamp) {
71         this.lastpressedtimestamp = lastpressedtimestamp;
72     }
73
74     @Override
75     public int hashCode() {
76         final int prime = 31;
77         int result = 1;
78         result = prime * result + (identifier != null ? identifier.hashCode() : 0);
79         result = prime * result + (buttonId != null ? buttonId.hashCode() : 0);
80         result = prime * result + (name != null ? name.hashCode() : 0);
81         return result;
82     }
83
84     @Override
85     public boolean equals(Object obj) {
86         if (this == obj) {
87             return true;
88         }
89         if (obj == null) {
90             return false;
91         }
92         if (getClass() != obj.getClass()) {
93             return false;
94         }
95         ButtonModel other = (ButtonModel) obj;
96         return (identifier != null ? identifier.equals(other.identifier) : other.identifier == null) && //
97                 (buttonId != null ? buttonId.equals(other.buttonId) : other.buttonId == null) && //
98                 (name != null ? name.equals(other.name) : other.name == null);
99     }
100
101     @Override
102     public String toString() {
103         return new StringBuilder().append("[identifier=").append(getIdentifier()).append(",id=").append(buttonId)
104                 .append(",name=").append(name).append(",lastpressedtimestamp=").append(lastpressedtimestamp).append("]")
105                 .toString();
106     }
107 }