]> git.basschouten.com Git - openhab-addons.git/blob
64e0f81f3b9264e7cdfa07f5cc4838e889fb46e3
[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.nest.internal.wwn.dto;
14
15 import java.util.Date;
16
17 /**
18  * Default properties shared across all WWN devices.
19  *
20  * @author David Bennett - Initial contribution
21  * @author Wouter Born - Add equals and hashCode methods
22  */
23 public class BaseWWNDevice implements WWNIdentifiable {
24
25     private String deviceId;
26     private String name;
27     private String nameLong;
28     private Date lastConnection;
29     private Boolean isOnline;
30     private String softwareVersion;
31     private String structureId;
32
33     private String whereId;
34
35     @Override
36     public String getId() {
37         return deviceId;
38     }
39
40     public String getName() {
41         return name;
42     }
43
44     public String getDeviceId() {
45         return deviceId;
46     }
47
48     public Date getLastConnection() {
49         return lastConnection;
50     }
51
52     public Boolean isOnline() {
53         return isOnline;
54     }
55
56     public String getNameLong() {
57         return nameLong;
58     }
59
60     public String getSoftwareVersion() {
61         return softwareVersion;
62     }
63
64     public String getStructureId() {
65         return structureId;
66     }
67
68     public String getWhereId() {
69         return whereId;
70     }
71
72     @Override
73     public boolean equals(Object obj) {
74         if (this == obj) {
75             return true;
76         }
77         if (obj == null) {
78             return false;
79         }
80         if (getClass() != obj.getClass()) {
81             return false;
82         }
83         BaseWWNDevice other = (BaseWWNDevice) obj;
84         if (deviceId == null) {
85             if (other.deviceId != null) {
86                 return false;
87             }
88         } else if (!deviceId.equals(other.deviceId)) {
89             return false;
90         }
91         if (isOnline == null) {
92             if (other.isOnline != null) {
93                 return false;
94             }
95         } else if (!isOnline.equals(other.isOnline)) {
96             return false;
97         }
98         if (lastConnection == null) {
99             if (other.lastConnection != null) {
100                 return false;
101             }
102         } else if (!lastConnection.equals(other.lastConnection)) {
103             return false;
104         }
105         if (name == null) {
106             if (other.name != null) {
107                 return false;
108             }
109         } else if (!name.equals(other.name)) {
110             return false;
111         }
112         if (nameLong == null) {
113             if (other.nameLong != null) {
114                 return false;
115             }
116         } else if (!nameLong.equals(other.nameLong)) {
117             return false;
118         }
119         if (softwareVersion == null) {
120             if (other.softwareVersion != null) {
121                 return false;
122             }
123         } else if (!softwareVersion.equals(other.softwareVersion)) {
124             return false;
125         }
126         if (structureId == null) {
127             if (other.structureId != null) {
128                 return false;
129             }
130         } else if (!structureId.equals(other.structureId)) {
131             return false;
132         }
133         if (whereId == null) {
134             if (other.whereId != null) {
135                 return false;
136             }
137         } else if (!whereId.equals(other.whereId)) {
138             return false;
139         }
140         return true;
141     }
142
143     @Override
144     public int hashCode() {
145         final int prime = 31;
146         int result = 1;
147         result = prime * result + ((deviceId == null) ? 0 : deviceId.hashCode());
148         result = prime * result + ((isOnline == null) ? 0 : isOnline.hashCode());
149         result = prime * result + ((lastConnection == null) ? 0 : lastConnection.hashCode());
150         result = prime * result + ((name == null) ? 0 : name.hashCode());
151         result = prime * result + ((nameLong == null) ? 0 : nameLong.hashCode());
152         result = prime * result + ((softwareVersion == null) ? 0 : softwareVersion.hashCode());
153         result = prime * result + ((structureId == null) ? 0 : structureId.hashCode());
154         result = prime * result + ((whereId == null) ? 0 : whereId.hashCode());
155         return result;
156     }
157
158     @Override
159     public String toString() {
160         StringBuilder builder = new StringBuilder();
161         builder.append("BaseNestDevice [deviceId=").append(deviceId).append(", name=").append(name)
162                 .append(", nameLong=").append(nameLong).append(", lastConnection=").append(lastConnection)
163                 .append(", isOnline=").append(isOnline).append(", softwareVersion=").append(softwareVersion)
164                 .append(", structureId=").append(structureId).append(", whereId=").append(whereId).append("]");
165         return builder.toString();
166     }
167 }