-
Notifications
You must be signed in to change notification settings - Fork 160
Expand file tree
/
Copy pathAccountEntryExtensionV3.java
More file actions
103 lines (91 loc) · 3.46 KB
/
AccountEntryExtensionV3.java
File metadata and controls
103 lines (91 loc) · 3.46 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
// Automatically generated by xdrgen
// DO NOT EDIT or your changes may be overwritten
package org.stellar.sdk.xdr;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.LinkedHashMap;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.stellar.sdk.Base64Factory;
/**
* AccountEntryExtensionV3's original definition in the XDR file is:
*
* <pre>
* struct AccountEntryExtensionV3
* {
* // We can use this to add more fields, or because it is first, to
* // change AccountEntryExtensionV3 into a union.
* ExtensionPoint ext;
*
* // Ledger number at which `seqNum` took on its present value.
* uint32 seqLedger;
*
* // Time at which `seqNum` took on its present value.
* TimePoint seqTime;
* };
* </pre>
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder(toBuilder = true)
public class AccountEntryExtensionV3 implements XdrElement {
private ExtensionPoint ext;
private Uint32 seqLedger;
private TimePoint seqTime;
public void encode(XdrDataOutputStream stream) throws IOException {
ext.encode(stream);
seqLedger.encode(stream);
seqTime.encode(stream);
}
public static AccountEntryExtensionV3 decode(XdrDataInputStream stream, int maxDepth)
throws IOException {
if (maxDepth <= 0) {
throw new IOException("Maximum decoding depth reached");
}
maxDepth -= 1;
AccountEntryExtensionV3 decodedAccountEntryExtensionV3 = new AccountEntryExtensionV3();
decodedAccountEntryExtensionV3.ext = ExtensionPoint.decode(stream, maxDepth);
decodedAccountEntryExtensionV3.seqLedger = Uint32.decode(stream, maxDepth);
decodedAccountEntryExtensionV3.seqTime = TimePoint.decode(stream, maxDepth);
return decodedAccountEntryExtensionV3;
}
public static AccountEntryExtensionV3 decode(XdrDataInputStream stream) throws IOException {
return decode(stream, XdrDataInputStream.DEFAULT_MAX_DEPTH);
}
public static AccountEntryExtensionV3 fromXdrBase64(String xdr) throws IOException {
byte[] bytes = Base64Factory.getInstance().decode(xdr);
return fromXdrByteArray(bytes);
}
public static AccountEntryExtensionV3 fromXdrByteArray(byte[] xdr) throws IOException {
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xdr);
XdrDataInputStream xdrDataInputStream = new XdrDataInputStream(byteArrayInputStream);
xdrDataInputStream.setMaxInputLen(xdr.length);
return decode(xdrDataInputStream);
}
@Override
public String toJson() {
return XdrElement.gson.toJson(toJsonObject());
}
public static AccountEntryExtensionV3 fromJson(String json) {
return fromJsonObject(XdrElement.gson.fromJson(json, Object.class));
}
Object toJsonObject() {
LinkedHashMap<String, Object> jsonMap = new LinkedHashMap<>();
jsonMap.put("ext", ext.toJsonObject());
jsonMap.put("seq_ledger", seqLedger.toJsonObject());
jsonMap.put("seq_time", seqTime.toJsonObject());
return jsonMap;
}
@SuppressWarnings("unchecked")
static AccountEntryExtensionV3 fromJsonObject(Object json) {
java.util.Map<String, Object> jsonMap = (java.util.Map<String, Object>) json;
AccountEntryExtensionV3 instance = new AccountEntryExtensionV3();
instance.ext = ExtensionPoint.fromJsonObject(jsonMap.get("ext"));
instance.seqLedger = Uint32.fromJsonObject(jsonMap.get("seq_ledger"));
instance.seqTime = TimePoint.fromJsonObject(jsonMap.get("seq_time"));
return instance;
}
}