aboutsummaryrefslogtreecommitdiffstats
path: root/language-web/src/main/java/tools/refinery/language/web/xtext/server/message/XtextWebErrorResponse.java
blob: 01d78c31188f5c08ae95d69c7ff25a08256f5210 (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
76
77
78
79
package tools.refinery.language.web.xtext.server.message;

import java.util.Objects;

import com.google.gson.annotations.SerializedName;

public final class XtextWebErrorResponse implements XtextWebResponse {
	private String id;

	@SerializedName("error")
	private XtextWebErrorKind errorKind;

	@SerializedName("message")
	private String errorMessage;

	public XtextWebErrorResponse(String id, XtextWebErrorKind errorKind, String errorMessage) {
		super();
		this.id = id;
		this.errorKind = errorKind;
		this.errorMessage = errorMessage;
	}

	public XtextWebErrorResponse(XtextWebRequest request, XtextWebErrorKind errorKind,
			String errorMessage) {
		this(request.getId(), errorKind, errorMessage);
	}

	public XtextWebErrorResponse(XtextWebRequest request, XtextWebErrorKind errorKind, Throwable t) {
		this(request, errorKind, t.getMessage());
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public XtextWebErrorKind getErrorKind() {
		return errorKind;
	}

	public void setErrorKind(XtextWebErrorKind errorKind) {
		this.errorKind = errorKind;
	}

	public String getErrorMessage() {
		return errorMessage;
	}

	public void setErrorMessage(String errorMessage) {
		this.errorMessage = errorMessage;
	}

	@Override
	public int hashCode() {
		return Objects.hash(errorKind, errorMessage, id);
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		XtextWebErrorResponse other = (XtextWebErrorResponse) obj;
		return errorKind == other.errorKind && Objects.equals(errorMessage, other.errorMessage)
				&& Objects.equals(id, other.id);
	}

	@Override
	public String toString() {
		return "XtextWebSocketErrorResponse [id=" + id + ", errorKind=" + errorKind + ", errorMessage=" + errorMessage
				+ "]";
	}
}