]> git.basschouten.com Git - openhab-addons.git/blob
e167afb5982b9a0057431ba2dabec6c34d228497
[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.mielecloud.internal.webservice.sse;
14
15 import java.util.Objects;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
19
20 /**
21  * An event emitted by an SSE connection.
22  *
23  * @author Björn Lange - Initial Contribution
24  */
25 @NonNullByDefault
26 public final class ServerSentEvent {
27     private final String event;
28     private final String data;
29
30     public ServerSentEvent(String event, String data) {
31         this.event = event;
32         this.data = data;
33     }
34
35     public String getEvent() {
36         return event;
37     }
38
39     public String getData() {
40         return data;
41     }
42
43     @Override
44     public int hashCode() {
45         return Objects.hash(event, data);
46     }
47
48     @Override
49     public boolean equals(@Nullable Object obj) {
50         if (this == obj) {
51             return true;
52         }
53         if (obj == null) {
54             return false;
55         }
56         if (getClass() != obj.getClass()) {
57             return false;
58         }
59         ServerSentEvent other = (ServerSentEvent) obj;
60         return Objects.equals(event, other.event) && Objects.equals(data, other.data);
61     }
62 }