-
Notifications
You must be signed in to change notification settings - Fork 160
Expand file tree
/
Copy pathAccountFlags.java
More file actions
87 lines (75 loc) · 2.54 KB
/
AccountFlags.java
File metadata and controls
87 lines (75 loc) · 2.54 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
// Automatically generated by xdrgen
// DO NOT EDIT or your changes may be overwritten
package org.stellar.sdk.xdr;
import java.io.IOException;
import org.stellar.sdk.Base64Factory;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.List;
import java.util.ArrayList;
/**
* AccountFlags's original definition in the XDR file is:
* <pre>
* enum AccountFlags
* { // masks for each flag
* AUTH_REQUIRED_FLAG = 0x1
* };
* </pre>
*/
public enum AccountFlags implements XdrElement {
AUTH_REQUIRED_FLAG(1);
private final int value;
AccountFlags(int value) {
this.value = value;
}
public int getValue() {
return value;
}
public static AccountFlags decode(XdrDataInputStream stream, int maxDepth) throws IOException {
// maxDepth is intentionally not checked - enums are leaf types with no recursive decoding
int value = stream.readInt();
switch (value) {
case 1: return AUTH_REQUIRED_FLAG;
default:
throw new IllegalArgumentException("Unknown enum value: " + value);
}
}
public static AccountFlags decode(XdrDataInputStream stream) throws IOException {
return decode(stream, XdrDataInputStream.DEFAULT_MAX_DEPTH);
}
public void encode(XdrDataOutputStream stream) throws IOException {
stream.writeInt(value);
}
public static AccountFlags fromXdrBase64(String xdr) throws IOException {
byte[] bytes = Base64Factory.getInstance().decode(xdr);
return fromXdrByteArray(bytes);
}
public static AccountFlags 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 AccountFlags fromJson(String json) {
return fromJsonObject(XdrElement.gson.fromJson(json, Object.class));
}
Object toJsonObject() {
switch (this) {
case AUTH_REQUIRED_FLAG: return "auth_required_flag";
default: throw new IllegalArgumentException("Unknown enum value: " + this.value);
}
}
static AccountFlags fromJsonObject(Object json) {
String value = (String) json;
switch (value) {
case "auth_required_flag": return AUTH_REQUIRED_FLAG;
default: throw new IllegalArgumentException("Unknown JSON value: " + value);
}
}
}