/
LRAData.java
133 lines (107 loc) · 3.21 KB
/
LRAData.java
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*
Copyright The Narayana Authors
SPDX-License-Identifier: Apache-2.0
*/
package io.narayana.lra;
import org.eclipse.microprofile.lra.annotation.LRAStatus;
import java.beans.Transient;
import java.net.URI;
/**
* DTO object which serves to transfer data of particular LRA instance.
* It's used by {@code io.narayana.lra.coordinator.api.Coordinator}
* for JSON response creation when LRA info is asked for.
*/
public class LRAData {
private URI lraId;
private String clientId;
private LRAStatus status;
private boolean isTopLevel;
private boolean isRecovering;
private long startTime;
private long finishTime;
private int httpStatus;
public LRAData() {}
public LRAData(URI lraId, String clientId, LRAStatus status, boolean isTopLevel, boolean isRecovering,
long startTime, long finishTime, int httpStatus) {
this.lraId = lraId;
this.clientId = clientId;
this.status = status;
this.isTopLevel = isTopLevel;
this.isRecovering = isRecovering;
this.startTime = startTime;
this.finishTime = finishTime;
this.httpStatus = httpStatus;
}
public URI getLraId() {
return this.lraId;
}
public void setLraId(URI lraId) {
this.lraId = lraId;
}
@Transient
public String getLraIdAsString() {
return this.lraId.toASCIIString();
}
public String getClientId() {
return this.clientId;
}
public void setClientId(String clientId) {
this.clientId = clientId;
}
public LRAStatus getStatus() {
return this.status;
}
public void setStatus(LRAStatus status) {
this.status = status;
}
public boolean isTopLevel() {
return this.isTopLevel;
}
public void setTopLevel(boolean topLevel) {
isTopLevel = topLevel;
}
public boolean isRecovering() {
return this.isRecovering;
}
public void setRecovering(boolean recovering) {
isRecovering = recovering;
}
public long getStartTime() {
return startTime;
}
public void setStartTime(long startTime) {
this.startTime = startTime;
}
public long getFinishTime() {
return finishTime;
}
public void setFinishTime(long finishTime) {
this.finishTime = finishTime;
}
public int getHttpStatus() {
return this.httpStatus;
}
public void setHttpStatus(int httpStatus) {
this.httpStatus = httpStatus;
}
public boolean equals(Object o) {
if (this == o) {
return true;
} else if (!(o instanceof LRAData)) {
return false;
} else {
LRAData lraData = (LRAData) o;
return this.getLraId().equals(lraData.getLraId());
}
}
public int hashCode() {
return this.getLraId().hashCode();
}
@Override
public String toString() {
return String.format(
"%s {lraId='%s', clientId='%s', status='%s', isTopLevel=%b, isRecovering=%b, startTime=%d, finishTime=%d, httpStatus=%d}",
this.getClass().getSimpleName(), lraId, clientId, status,
isTopLevel, isRecovering, startTime, finishTime, httpStatus);
}
}