]> git.basschouten.com Git - openhab-addons.git/blob
59b45181b1b3eeaf1bf5c8ca103db7f75629a780
[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.verisure.internal.dto;
14
15 import java.util.ArrayList;
16 import java.util.List;
17
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
20
21 /**
22  * The SmartLock state of the Verisure System.
23  *
24  * @author Jan Gustafsson - Initial contribution
25  *
26  */
27 @NonNullByDefault
28 public class VerisureSmartLockDTO {
29
30     private boolean autoRelockEnabled;
31     private @Nullable String deviceLabel;
32     private DoorLockVolumeSettings doorLockVolumeSettings = new DoorLockVolumeSettings();
33
34     public boolean getAutoRelockEnabled() {
35         return autoRelockEnabled;
36     }
37
38     public @Nullable String getDeviceLabel() {
39         return deviceLabel;
40     }
41
42     public DoorLockVolumeSettings getDoorLockVolumeSettings() {
43         return doorLockVolumeSettings;
44     }
45
46     public static class DoorLockVolumeSettings {
47         private @Nullable String volume;
48         private @Nullable String voiceLevel;
49         private @Nullable String active;
50         private List<String> availableVolumes = new ArrayList<>();
51         private List<String> availableVoiceLevels = new ArrayList<>();
52
53         public @Nullable String getVolume() {
54             return volume;
55         }
56
57         public @Nullable String getVoiceLevel() {
58             return voiceLevel;
59         }
60
61         public @Nullable String getActive() {
62             return active;
63         }
64
65         public List<String> getAvailableVolumes() {
66             return availableVolumes;
67         }
68
69         public List<String> getAvailableVoiceLevels() {
70             return availableVoiceLevels;
71         }
72
73         @Override
74         public int hashCode() {
75             final int prime = 31;
76             int result = 1;
77             String localActive = active;
78             result = prime * result + ((localActive == null) ? 0 : localActive.hashCode());
79             result = prime * result + availableVoiceLevels.hashCode();
80             result = prime * result + availableVolumes.hashCode();
81             String localVoiceLevel = voiceLevel;
82             result = prime * result + ((localVoiceLevel == null) ? 0 : localVoiceLevel.hashCode());
83             String localVolume = volume;
84             result = prime * result + ((localVolume == null) ? 0 : localVolume.hashCode());
85             return result;
86         }
87
88         @Override
89         public boolean equals(@Nullable Object obj) {
90             if (this == obj) {
91                 return true;
92             }
93             if (obj == null) {
94                 return false;
95             }
96             if (getClass() != obj.getClass()) {
97                 return false;
98             }
99             DoorLockVolumeSettings other = (DoorLockVolumeSettings) obj;
100             String localActive = active;
101             if (localActive == null) {
102                 if (other.active != null) {
103                     return false;
104                 }
105             } else if (!localActive.equals(other.active)) {
106                 return false;
107             }
108             if (!availableVoiceLevels.equals(other.availableVoiceLevels)) {
109                 return false;
110             }
111             if (!availableVolumes.equals(other.availableVolumes)) {
112                 return false;
113             }
114             String localVoiceLevel = voiceLevel;
115             if (localVoiceLevel == null) {
116                 if (other.voiceLevel != null) {
117                     return false;
118                 }
119             } else if (!localVoiceLevel.equals(other.voiceLevel)) {
120                 return false;
121             }
122             String localVolume = volume;
123             if (localVolume == null) {
124                 if (other.volume != null) {
125                     return false;
126                 }
127             } else if (!localVolume.equals(other.volume)) {
128                 return false;
129             }
130             return true;
131         }
132
133         @Override
134         public String toString() {
135             return "DoorLockVolumeSettings [volume=" + volume + ", voiceLevel=" + voiceLevel + ", active=" + active
136                     + ", availableVolumes=" + availableVolumes + ", availableVoiceLevels=" + availableVoiceLevels + "]";
137         }
138     }
139
140     @Override
141     public int hashCode() {
142         final int prime = 31;
143         int result = 1;
144         result = prime * result + (autoRelockEnabled ? 1231 : 1237);
145         String localDeviceLabel = deviceLabel;
146         result = prime * result + ((localDeviceLabel == null) ? 0 : localDeviceLabel.hashCode());
147         result = prime * result + doorLockVolumeSettings.hashCode();
148         return result;
149     }
150
151     @SuppressWarnings("PMD.SimplifyBooleanReturns")
152     @Override
153     public boolean equals(@Nullable Object obj) {
154         if (this == obj) {
155             return true;
156         }
157         if (obj == null) {
158             return false;
159         }
160         if (getClass() != obj.getClass()) {
161             return false;
162         }
163         VerisureSmartLockDTO other = (VerisureSmartLockDTO) obj;
164         if (autoRelockEnabled != other.autoRelockEnabled) {
165             return false;
166         }
167         String localDeviceLabel = deviceLabel;
168         if (localDeviceLabel == null) {
169             if (other.deviceLabel != null) {
170                 return false;
171             }
172         } else if (!localDeviceLabel.equals(other.deviceLabel)) {
173             return false;
174         }
175         if (!doorLockVolumeSettings.equals(other.doorLockVolumeSettings)) {
176             return false;
177         }
178         return true;
179     }
180
181     @Override
182     public String toString() {
183         return "VerisureSmartLockDTO [autoRelockEnabled=" + autoRelockEnabled + ", deviceLabel=" + deviceLabel
184                 + ", doorLockVolumeSettings=" + doorLockVolumeSettings + "]";
185     }
186 }