]> git.basschouten.com Git - openhab-addons.git/blob
1490e8256e4b28c6a8807d8cd3fec09e3fe334b5
[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.groupepsa.internal.rest.api.dto;
14
15 import java.time.ZonedDateTime;
16 import java.util.List;
17
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
20
21 import com.google.gson.annotations.SerializedName;
22
23 /**
24  * @author Arjan Mels - Initial contribution
25  */
26 @NonNullByDefault
27 public class VehicleStatus {
28
29     private @Nullable ZonedDateTime updatedAt;
30     @SerializedName("_embedded")
31     private @Nullable Embedded embedded;
32     private @Nullable Battery battery;
33     private @Nullable DoorsState doorsState;
34     private @Nullable List<Energy> energy = null;
35     private @Nullable Environment environment;
36     private @Nullable Ignition ignition;
37     private @Nullable Kinetic kinetic;
38     @SerializedName("timed.odometer")
39     private @Nullable Odometer odometer;
40     private @Nullable Position lastPosition;
41     private @Nullable Preconditionning preconditionning;
42     private @Nullable Privacy privacy;
43     private @Nullable Safety safety;
44     private @Nullable Service service;
45
46     private static class Embedded {
47         private @Nullable Extension extension;
48
49         @Override
50         public String toString() {
51             return new ToStringBuilder(this).append("extension", extension).toString();
52         }
53     }
54
55     private static class Extension {
56         private @Nullable Kinetic kinetic;
57         private @Nullable Odometer odometer;
58
59         @Override
60         public String toString() {
61             return new ToStringBuilder(this).append("kinetic", kinetic).append("odometer", odometer).toString();
62         }
63     }
64
65     public @Nullable Kinetic getKinetic() {
66         if (kinetic != null) {
67             return kinetic;
68         } else {
69             final Embedded finalEmbedded = embedded;
70             if (finalEmbedded != null) {
71                 final Extension finalExtension = finalEmbedded.extension;
72                 if (finalExtension != null) {
73                     return finalExtension.kinetic;
74                 }
75             }
76             return null;
77         }
78     }
79
80     public @Nullable Odometer getOdometer() {
81         if (odometer != null) {
82             return odometer;
83         } else {
84             Embedded finalEmbedded = embedded;
85             if (finalEmbedded != null) {
86                 final Extension finalExtension = finalEmbedded.extension;
87                 if (finalExtension != null) {
88                     return finalExtension.odometer;
89                 }
90             }
91             return null;
92         }
93     }
94
95     public @Nullable ZonedDateTime getUpdatedAt() {
96         return updatedAt;
97     }
98
99     public @Nullable Battery getBattery() {
100         return battery;
101     }
102
103     public @Nullable DoorsState getDoorsState() {
104         return doorsState;
105     }
106
107     public @Nullable List<Energy> getEnergy() {
108         return energy;
109     }
110
111     public @Nullable Environment getEnvironment() {
112         return environment;
113     }
114
115     public @Nullable Ignition getIgnition() {
116         return ignition;
117     }
118
119     public @Nullable Position getLastPosition() {
120         return lastPosition;
121     }
122
123     public @Nullable Preconditionning getPreconditionning() {
124         return preconditionning;
125     }
126
127     public @Nullable Privacy getPrivacy() {
128         return privacy;
129     }
130
131     public @Nullable Safety getSafety() {
132         return safety;
133     }
134
135     public @Nullable Service getService() {
136         return service;
137     }
138
139     @Override
140     public String toString() {
141         return new ToStringBuilder(this).append("updatedAt", updatedAt).append("_embedded", embedded)
142                 .append("battery", battery).append("doorsState", doorsState).append("energy", energy)
143                 .append("environment", environment).append("ignition", ignition).append("kinetic", kinetic)
144                 .append("odometer", odometer).append("lastPosition", lastPosition)
145                 .append("preconditionning", preconditionning).append("privacy", privacy).append("safety", safety)
146                 .append("service", service).toString();
147     }
148 }