-
Notifications
You must be signed in to change notification settings - Fork 768
Expand file tree
/
Copy pathUserDataUpdateEvent.java
More file actions
125 lines (98 loc) · 3.96 KB
/
UserDataUpdateEvent.java
File metadata and controls
125 lines (98 loc) · 3.96 KB
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
package com.binance.api.client.domain.event;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* User data update event which can be of two types:
*
* 1) outboundAccountInfo, whenever there is a change in the account (e.g. balance of an asset)
* 2) executionReport, whenever there is a trade or an order
*/
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonDeserialize(using = UserDataUpdateEventDeserializer.class)
public class UserDataUpdateEvent {
private UserDataUpdateEventType eventType;
private long eventTime;
private AccountUpdateEvent accountUpdateEvent;
private OrderTradeUpdateEvent orderTradeUpdateEvent;
private OutboundAccountPositionEvent outboundAccountPositionEvent;
private ListStatusEvent listStatusEvent;
public UserDataUpdateEventType getEventType() {
return eventType;
}
public void setEventType(UserDataUpdateEventType eventType) {
this.eventType = eventType;
}
public long getEventTime() {
return eventTime;
}
public void setEventTime(long eventTime) {
this.eventTime = eventTime;
}
public AccountUpdateEvent getAccountUpdateEvent() {
return accountUpdateEvent;
}
public void setAccountUpdateEvent(AccountUpdateEvent accountUpdateEvent) {
this.accountUpdateEvent = accountUpdateEvent;
}
public OrderTradeUpdateEvent getOrderTradeUpdateEvent() {
return orderTradeUpdateEvent;
}
public void setOrderTradeUpdateEvent(OrderTradeUpdateEvent orderTradeUpdateEvent) {
this.orderTradeUpdateEvent = orderTradeUpdateEvent;
}
public OutboundAccountPositionEvent getOutboundAccountPositionEvent() {
return outboundAccountPositionEvent;
}
public void setOutboundAccountPositionEvent(OutboundAccountPositionEvent outboundAccountPositionEvent) {
this.outboundAccountPositionEvent = outboundAccountPositionEvent;
}
public ListStatusEvent getListStatusEvent() {
return listStatusEvent;
}
public void setListStatusEvent(ListStatusEvent listStatusEvent) {
this.listStatusEvent = listStatusEvent;
}
@Override
public String toString() {
ToStringBuilder sb = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
.append("eventType", eventType)
.append("eventTime", eventTime);
if (eventType == UserDataUpdateEventType.ACCOUNT_UPDATE) {
sb.append("accountUpdateEvent", accountUpdateEvent);
} else if (eventType == UserDataUpdateEventType.ORDER_TRADE_UPDATE) {
sb.append("orderTradeUpdateEvent", orderTradeUpdateEvent);
} else if (eventType == UserDataUpdateEventType.OUTBOUND_ACCOUNT_POSITION) {
sb.append("outboundAccountPositionEvent", outboundAccountPositionEvent);
} else if (eventType == UserDataUpdateEventType.LIST_STATUS) {
sb.append("listStatusEvent", listStatusEvent);
}
return sb.toString();
}
public enum UserDataUpdateEventType {
ACCOUNT_UPDATE("outboundAccountInfo"),
ORDER_TRADE_UPDATE("executionReport"),
OUTBOUND_ACCOUNT_POSITION("outboundAccountPosition"),
LIST_STATUS("listStatus");
private final String eventTypeId;
UserDataUpdateEventType(String eventTypeId) {
this.eventTypeId = eventTypeId;
}
public String getEventTypeId() {
return eventTypeId;
}
public static UserDataUpdateEventType fromEventTypeId(String eventTypeId) {
if (ACCOUNT_UPDATE.eventTypeId.equals(eventTypeId)) {
return ACCOUNT_UPDATE;
} else if (ORDER_TRADE_UPDATE.eventTypeId.equals(eventTypeId)) {
return ORDER_TRADE_UPDATE;
} else if (OUTBOUND_ACCOUNT_POSITION.eventTypeId.equals(eventTypeId)) {
return OUTBOUND_ACCOUNT_POSITION;
} else if (LIST_STATUS.eventTypeId.equals(eventTypeId)) {
return LIST_STATUS;
}
throw new IllegalArgumentException("Unrecognized user data update event type id: " + eventTypeId);
}
}
}