]> git.basschouten.com Git - openhab-addons.git/blob
eb2afa2557a16edc8f191609ef3e54cb36cf934d
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2020 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.dwdunwetter.internal.data;
14
15 import java.math.BigDecimal;
16 import java.time.Instant;
17
18 import org.apache.commons.lang.StringUtils;
19
20 /**
21  * Data for one warning.
22  *
23  * @author Martin Koehler - Initial contribution
24  */
25 public class DwdWarningData {
26
27     private String id;
28
29     private Severity severity;
30     private String description;
31     private Instant effective;
32     private Instant expires;
33     private Instant onset;
34     private String event;
35     private String status;
36     private String msgType;
37     private String headline;
38     private BigDecimal altitude;
39     private BigDecimal ceiling;
40     private String instruction;
41     private Urgency urgency;
42
43     public void setId(String id) {
44         this.id = id;
45     }
46
47     public String getId() {
48         return id;
49     }
50
51     public void setSeverity(Severity severity) {
52         this.severity = severity;
53     }
54
55     public Severity getSeverity() {
56         return severity == null ? Severity.UNKNOWN : severity;
57     }
58
59     public void setDescription(String description) {
60         this.description = description;
61     }
62
63     public String getDescription() {
64         return description;
65     }
66
67     public void setEffective(Instant effective) {
68         this.effective = effective;
69     }
70
71     public Instant getEffective() {
72         return effective;
73     }
74
75     public void setExpires(Instant expires) {
76         this.expires = expires;
77     }
78
79     public Instant getExpires() {
80         return expires;
81     }
82
83     public void setEvent(String event) {
84         this.event = event;
85     }
86
87     public String getEvent() {
88         return event;
89     }
90
91     public void setStatus(String status) {
92         this.status = status;
93     }
94
95     public boolean isTest() {
96         return StringUtils.equalsIgnoreCase(status, "Test");
97     }
98
99     public void setMsgType(String msgType) {
100         this.msgType = msgType;
101     }
102
103     public boolean isCancel() {
104         return StringUtils.equalsIgnoreCase(msgType, "Cancel");
105     }
106
107     public void setHeadline(String headline) {
108         this.headline = headline;
109     }
110
111     public String getHeadline() {
112         return headline;
113     }
114
115     public Instant getOnset() {
116         return onset;
117     }
118
119     public void setOnset(Instant onset) {
120         this.onset = onset;
121     }
122
123     public void setAltitude(BigDecimal altitude) {
124         this.altitude = altitude;
125     }
126
127     public BigDecimal getAltitude() {
128         return altitude;
129     }
130
131     public void setCeiling(BigDecimal ceiling) {
132         this.ceiling = ceiling;
133     }
134
135     public BigDecimal getCeiling() {
136         return ceiling;
137     }
138
139     public void setInstruction(String instruction) {
140         this.instruction = instruction;
141     }
142
143     public String getInstruction() {
144         return instruction;
145     }
146
147     public void setUrgency(Urgency urgency) {
148         this.urgency = urgency;
149     }
150
151     public Urgency getUrgency() {
152         return urgency;
153     }
154
155     @Override
156     public int hashCode() {
157         final int prime = 31;
158         int result = 1;
159         result = prime * result + ((id == null) ? 0 : id.hashCode());
160         return result;
161     }
162
163     @Override
164     public boolean equals(Object obj) {
165         if (this == obj) {
166             return true;
167         }
168         if (obj == null) {
169             return false;
170         }
171         if (getClass() != obj.getClass()) {
172             return false;
173         }
174         DwdWarningData other = (DwdWarningData) obj;
175         if (id == null) {
176             if (other.id != null) {
177                 return false;
178             }
179         } else if (!id.equals(other.id)) {
180             return false;
181         }
182         return true;
183     }
184 }