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.verisure.internal.dto;
15 import static org.openhab.binding.verisure.internal.VerisureBindingConstants.THING_TYPE_DOORWINDOW;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
19 import org.openhab.core.thing.ThingTypeUID;
21 import com.google.gson.annotations.SerializedName;
24 * The door and window devices of the Verisure System.
26 * @author Jan Gustafsson - Initial contribution
30 public class VerisureDoorWindowsDTO extends VerisureBaseThingDTO {
32 private @Nullable VerisureBatteryStatusDTO batteryStatus;
34 public @Nullable VerisureBatteryStatusDTO getBatteryStatus() {
38 public void setBatteryStatus(@Nullable VerisureBatteryStatusDTO batteryStatus) {
39 this.batteryStatus = batteryStatus;
43 public ThingTypeUID getThingTypeUID() {
44 return THING_TYPE_DOORWINDOW;
48 public int hashCode() {
49 return super.hashCode();
53 public boolean equals(@Nullable Object obj) {
57 if (!super.equals(obj)) {
63 if (getClass() != obj.getClass()) {
66 VerisureDoorWindowsDTO other = (VerisureDoorWindowsDTO) obj;
67 VerisureBatteryStatusDTO localBatteryStatusJSON = batteryStatus;
68 if (localBatteryStatusJSON == null) {
69 if (other.batteryStatus != null) {
72 } else if (!localBatteryStatusJSON.equals(other.batteryStatus)) {
78 public static class DoorWindow {
80 private Device device = new Device();
81 private @Nullable String type;
82 private @Nullable String state;
83 private boolean wired;
84 private @Nullable String reportTime;
85 @SerializedName("__typename")
86 private @Nullable String typename;
88 public Device getDevice() {
92 public @Nullable String getType() {
96 public @Nullable String getState() {
100 public boolean getWired() {
104 public @Nullable String getReportTime() {
108 public @Nullable String getTypename() {
113 public int hashCode() {
114 final int prime = 31;
116 result = prime * result + device.hashCode();
117 String localReportTime = reportTime;
118 result = prime * result + ((localReportTime == null) ? 0 : localReportTime.hashCode());
119 String localState = state;
120 result = prime * result + ((localState == null) ? 0 : localState.hashCode());
121 String localType = type;
122 result = prime * result + ((localType == null) ? 0 : localType.hashCode());
123 String localTypeName = typename;
124 result = prime * result + ((localTypeName == null) ? 0 : localTypeName.hashCode());
125 result = prime * result + (wired ? 1231 : 1237);
129 @SuppressWarnings("PMD.SimplifyBooleanReturns")
131 public boolean equals(@Nullable Object obj) {
138 if (getClass() != obj.getClass()) {
141 DoorWindow other = (DoorWindow) obj;
142 if (!device.equals(other.device)) {
145 String localReportTime = reportTime;
146 if (localReportTime == null) {
147 if (other.reportTime != null) {
150 } else if (!localReportTime.equals(other.reportTime)) {
153 String localState = state;
154 if (localState == null) {
155 if (other.state != null) {
158 } else if (!localState.equals(other.state)) {
161 String localType = type;
162 if (localType == null) {
163 if (other.type != null) {
166 } else if (!localType.equals(other.type)) {
169 String localTypeName = typename;
170 if (localTypeName == null) {
171 if (other.typename != null) {
174 } else if (!localTypeName.equals(other.typename)) {
177 if (wired != other.wired) {
184 public String toString() {
185 return "DoorWindow [device=" + device + ", type=" + type + ", state=" + state + ", wired=" + wired
186 + ", reportTime=" + reportTime + ", typename=" + typename + "]";