]> git.basschouten.com Git - openhab-addons.git/blob
225ed4c1ee710c58c1c346cb1f167e16f9989926
[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.surepetcare.internal.dto;
14
15 import java.math.BigDecimal;
16 import java.time.LocalDate;
17 import java.util.Arrays;
18 import java.util.Map;
19
20 import org.eclipse.jdt.annotation.NonNull;
21
22 import com.google.gson.annotations.SerializedName;
23
24 /**
25  * The {@link SurePetcarePet} is a DTO class used to represent a pet. It's used to deserialize JSON API results.
26  *
27  * @author Rene Scherer - Initial contribution
28  */
29 public class SurePetcarePet extends SurePetcareBaseObject {
30
31     public enum PetGender {
32
33         UNKNONWN(-1, "Unknown"),
34         FEMALE(0, "Female"),
35         MALE(1, "Male");
36
37         public final Integer id;
38         public final String name;
39
40         private PetGender(int id, String name) {
41             this.id = id;
42             this.name = name;
43         }
44
45         public static PetGender findByTypeId(final int id) {
46             return Arrays.stream(values()).filter(value -> value.id.equals(id)).findFirst().orElse(UNKNONWN);
47         }
48     }
49
50     public enum PetSpecies {
51
52         UNKNONWN(0, "Unknown"),
53         CAT(1, "Cat"),
54         DOG(2, "Dog");
55
56         public final Integer id;
57         public final String name;
58
59         private PetSpecies(int id, String name) {
60             this.id = id;
61             this.name = name;
62         }
63
64         public static PetSpecies findByTypeId(final int id) {
65             return Arrays.stream(values()).filter(value -> value.id.equals(id)).findFirst().orElse(UNKNONWN);
66         }
67     }
68
69     public String name = "";
70
71     @SerializedName("gender")
72     public Integer genderId;
73     public LocalDate dateOfBirth;
74     public BigDecimal weight;
75     public String comments;
76     public Long householdId;
77     public Integer breedId;
78     public Long photoId;
79     public Integer speciesId;
80     public Long tagId;
81     public SurePetcarePhoto photo;
82
83     public SurePetcarePetStatus status = new SurePetcarePetStatus();
84
85     @Override
86     public String toString() {
87         return "Pet [id=" + id + ", name=" + name + ", tagId=" + tagId + "]";
88     }
89
90     @Override
91     public @NonNull Map<@NonNull String, @NonNull String> getThingProperties() {
92         @NonNull
93         Map<@NonNull String, @NonNull String> properties = super.getThingProperties();
94         properties.put("householdId", householdId.toString());
95         return properties;
96     }
97 }