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.sleepiq.internal.api.dto;
15 import org.openhab.binding.sleepiq.internal.api.enums.Side;
17 import com.google.gson.annotations.SerializedName;
20 * The {@link Sleeper} holds the information about the sleeper that's
21 * associated with a bed side.
23 * @author Gregory Moyer - Initial contribution
25 public class Sleeper {
26 private String firstName;
27 private Boolean active;
28 private Boolean emailValidated;
29 @SerializedName("isChild")
30 private Boolean child;
32 private String birthYear;
33 private String zipCode;
34 private String timezone;
35 @SerializedName("isMale")
37 private Integer weight; // lbs
38 private String duration;
39 private String sleeperId;
40 private Integer height; // inches
41 private Long licenseVersion;
42 private String username;
43 private Integer birthMonth; // 0-based; 12 means not entered?
44 private Integer sleepGoal;
45 @SerializedName("isAccountOwner")
46 private Boolean accountOwner;
47 private String accountId;
49 private String avatar;
50 private String lastLogin; // should be ZonedDateTime but provider passes string "null" when missing
51 private Side side; // 0=left; 1=right
53 public String getFirstName() {
57 public void setFirstName(String firstName) {
58 this.firstName = firstName;
61 public Sleeper withFirstName(String firstName) {
62 setFirstName(firstName);
66 public Boolean isActive() {
70 public void setActive(Boolean active) {
74 public Sleeper withActive(Boolean active) {
79 public Boolean isEmailValidated() {
80 return emailValidated;
83 public void setEmailValidated(Boolean emailValidated) {
84 this.emailValidated = emailValidated;
87 public Sleeper withEmailValidated(Boolean emailValidated) {
88 setEmailValidated(emailValidated);
92 public Boolean isChild() {
96 public void setChild(Boolean child) {
100 public Sleeper withChild(Boolean child) {
105 public String getBedId() {
109 public void setBedId(String bedId) {
113 public Sleeper withBedId(String bedId) {
118 public String getBirthYear() {
122 public void setBirthYear(String birthYear) {
123 this.birthYear = birthYear;
126 public Sleeper withBirthYear(String birthYear) {
127 setBirthYear(birthYear);
131 public String getZipCode() {
135 public void setZipCode(String zipCode) {
136 this.zipCode = zipCode;
139 public Sleeper withZipCode(String zipCode) {
144 public String getTimezone() {
148 public void setTimezone(String timezone) {
149 this.timezone = timezone;
152 public Sleeper withTimezone(String timezone) {
153 setTimezone(timezone);
157 public Boolean isMale() {
161 public void setMale(Boolean male) {
165 public Sleeper withMale(Boolean male) {
170 public Integer getWeight() {
174 public void setWeight(Integer weight) {
175 this.weight = weight;
178 public Sleeper withWeight(Integer weight) {
183 public String getDuration() {
187 public void setDuration(String duration) {
188 this.duration = duration;
191 public Sleeper withDuration(String duration) {
192 setDuration(duration);
196 public String getSleeperId() {
200 public void setSleeperId(String sleeperId) {
201 this.sleeperId = sleeperId;
204 public Sleeper withSleeperId(String sleeperId) {
205 setSleeperId(sleeperId);
209 public Integer getHeight() {
213 public void setHeight(Integer height) {
214 this.height = height;
217 public Sleeper withHeight(Integer height) {
222 public Long getLicenseVersion() {
223 return licenseVersion;
226 public void setLicenseVersion(Long licenseVersion) {
227 this.licenseVersion = licenseVersion;
230 public Sleeper withLicenseVersion(Long licenseVersion) {
231 setLicenseVersion(licenseVersion);
235 public String getUsername() {
239 public void setUsername(String username) {
240 this.username = username;
243 public Sleeper withUsername(String username) {
244 setUsername(username);
248 public Integer getBirthMonth() {
252 public void setBirthMonth(Integer birthMonth) {
253 this.birthMonth = birthMonth;
256 public Sleeper withBirthMonth(Integer birthMonth) {
257 setBirthMonth(birthMonth);
261 public Integer getSleepGoal() {
265 public void setSleepGoal(Integer sleepGoal) {
266 this.sleepGoal = sleepGoal;
269 public Sleeper withSleepGoal(Integer sleepGoal) {
270 setSleepGoal(sleepGoal);
274 public Boolean isAccountOwner() {
278 public void setAccountOwner(Boolean accountOwner) {
279 this.accountOwner = accountOwner;
282 public Sleeper withAccountOwner(Boolean accountOwner) {
283 setAccountOwner(accountOwner);
287 public String getAccountId() {
291 public void setAccountId(String accountId) {
292 this.accountId = accountId;
295 public Sleeper withAccountId(String accountId) {
296 setAccountId(accountId);
300 public String getEmail() {
304 public void setEmail(String email) {
308 public Sleeper withEmail(String email) {
313 public String getAvatar() {
317 public void setAvatar(String avatar) {
318 this.avatar = avatar;
321 public Sleeper withAvatar(String avatar) {
326 public String getLastLogin() {
330 public void setLastLogin(String lastLogin) {
331 this.lastLogin = lastLogin;
334 public Sleeper withLastLogin(String lastLogin) {
335 setLastLogin(lastLogin);
339 public Side getSide() {
343 public void setSide(Side side) {
347 public Sleeper withSide(Side side) {
353 public int hashCode() {
354 final int prime = 31;
356 result = prime * result + ((sleeperId == null) ? 0 : sleeperId.hashCode());
361 public boolean equals(Object obj) {
368 if (!(obj instanceof Sleeper)) {
371 Sleeper other = (Sleeper) obj;
372 if (sleeperId == null) {
373 if (other.sleeperId != null) {
376 } else if (!sleeperId.equals(other.sleeperId)) {
383 public String toString() {
384 StringBuilder builder = new StringBuilder();
385 builder.append("Sleeper [firstName=");
386 builder.append(firstName);
387 builder.append(", active=");
388 builder.append(active);
389 builder.append(", emailValidated=");
390 builder.append(emailValidated);
391 builder.append(", child=");
392 builder.append(child);
393 builder.append(", bedId=");
394 builder.append(bedId);
395 builder.append(", birthYear=");
396 builder.append(birthYear);
397 builder.append(", zipCode=");
398 builder.append(zipCode);
399 builder.append(", timezone=");
400 builder.append(timezone);
401 builder.append(", male=");
402 builder.append(male);
403 builder.append(", weight=");
404 builder.append(weight);
405 builder.append(", duration=");
406 builder.append(duration);
407 builder.append(", sleeperId=");
408 builder.append(sleeperId);
409 builder.append(", height=");
410 builder.append(height);
411 builder.append(", licenseVersion=");
412 builder.append(licenseVersion);
413 builder.append(", username=");
414 builder.append(username);
415 builder.append(", birthMonth=");
416 builder.append(birthMonth);
417 builder.append(", sleepGoal=");
418 builder.append(sleepGoal);
419 builder.append(", accountOwner=");
420 builder.append(accountOwner);
421 builder.append(", accountId=");
422 builder.append(accountId);
423 builder.append(", email=");
424 builder.append(email);
425 builder.append(", avatar=");
426 builder.append(avatar);
427 builder.append(", lastLogin=");
428 builder.append(lastLogin);
429 builder.append(", side=");
430 builder.append(side);
432 return builder.toString();