blob: c3379329a4be0991bd86c98ff528b17e96d09863 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
/*
* SPDX-FileCopyrightText: 2021-2023 The Refinery Authors <https://refinery.tools/>
*
* SPDX-License-Identifier: EPL-2.0
*/
package tools.refinery.language.web.xtext.server.message;
import com.google.gson.annotations.SerializedName;
import org.eclipse.xtext.web.server.IServiceResult;
import org.eclipse.xtext.web.server.IUnwrappableServiceResult;
import java.util.Objects;
public final class XtextWebOkResponse implements XtextWebResponse {
private String id;
@SerializedName("response")
private Object responseData;
public XtextWebOkResponse(String id, Object responseData) {
this.id = id;
this.responseData = responseData;
}
public XtextWebOkResponse(XtextWebRequest request, IServiceResult result) {
this(request.getId(), maybeUnwrap(result));
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public Object getResponseData() {
return responseData;
}
public void setResponseData(Object responseData) {
this.responseData = responseData;
}
@Override
public int hashCode() {
return Objects.hash(id, responseData);
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
XtextWebOkResponse other = (XtextWebOkResponse) obj;
return Objects.equals(id, other.id) && Objects.equals(responseData, other.responseData);
}
@Override
public String toString() {
return "XtextWebSocketOkResponse [id=" + id + ", responseData=" + responseData + "]";
}
private static Object maybeUnwrap(IServiceResult result) {
if (result instanceof IUnwrappableServiceResult unwrappableServiceResult
&& unwrappableServiceResult.getContent() != null) {
return unwrappableServiceResult.getContent();
} else {
return result;
}
}
}
|