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.nest.internal.wwn.dto;
15 import java.util.Date;
18 * Default properties shared across all WWN devices.
20 * @author David Bennett - Initial contribution
21 * @author Wouter Born - Add equals and hashCode methods
23 public class BaseWWNDevice implements WWNIdentifiable {
25 private String deviceId;
27 private String nameLong;
28 private Date lastConnection;
29 private Boolean isOnline;
30 private String softwareVersion;
31 private String structureId;
33 private String whereId;
36 public String getId() {
40 public String getName() {
44 public String getDeviceId() {
48 public Date getLastConnection() {
49 return lastConnection;
52 public Boolean isOnline() {
56 public String getNameLong() {
60 public String getSoftwareVersion() {
61 return softwareVersion;
64 public String getStructureId() {
68 public String getWhereId() {
73 public boolean equals(Object obj) {
80 if (getClass() != obj.getClass()) {
83 BaseWWNDevice other = (BaseWWNDevice) obj;
84 if (deviceId == null) {
85 if (other.deviceId != null) {
88 } else if (!deviceId.equals(other.deviceId)) {
91 if (isOnline == null) {
92 if (other.isOnline != null) {
95 } else if (!isOnline.equals(other.isOnline)) {
98 if (lastConnection == null) {
99 if (other.lastConnection != null) {
102 } else if (!lastConnection.equals(other.lastConnection)) {
106 if (other.name != null) {
109 } else if (!name.equals(other.name)) {
112 if (nameLong == null) {
113 if (other.nameLong != null) {
116 } else if (!nameLong.equals(other.nameLong)) {
119 if (softwareVersion == null) {
120 if (other.softwareVersion != null) {
123 } else if (!softwareVersion.equals(other.softwareVersion)) {
126 if (structureId == null) {
127 if (other.structureId != null) {
130 } else if (!structureId.equals(other.structureId)) {
133 if (whereId == null) {
134 if (other.whereId != null) {
137 } else if (!whereId.equals(other.whereId)) {
144 public int hashCode() {
145 final int prime = 31;
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());
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();