This repository has been archived by the owner on Feb 6, 2019. It is now read-only.
/
BucketEntry.java
67 lines (61 loc) · 1.86 KB
/
BucketEntry.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
// Automatically generated on 2015-11-05T11:21:06-08:00
// DO NOT EDIT or your changes may be overwritten
package org.stellar.base.xdr;
import java.io.IOException;
// === xdr source ============================================================
// union BucketEntry switch (BucketEntryType type)
// {
// case LIVEENTRY:
// LedgerEntry liveEntry;
//
// case DEADENTRY:
// LedgerKey deadEntry;
// };
// ===========================================================================
public class BucketEntry {
public BucketEntry () {}
BucketEntryType type;
public BucketEntryType getDiscriminant() {
return this.type;
}
public void setDiscriminant(BucketEntryType value) {
this.type = value;
}
private LedgerEntry liveEntry;
public LedgerEntry getliveEntry() {
return this.liveEntry;
}
public void setliveEntry(LedgerEntry value) {
this.liveEntry = value;
}
private LedgerKey deadEntry;
public LedgerKey getdeadEntry() {
return this.deadEntry;
}
public void setdeadEntry(LedgerKey value) {
this.deadEntry = value;
}
public static void encode(XdrDataOutputStream stream, BucketEntry encodedBucketEntry) throws IOException {
stream.writeInt(encodedBucketEntry.getDiscriminant().getValue());
switch (encodedBucketEntry.getDiscriminant()) {
case LIVEENTRY:
LedgerEntry.encode(stream, encodedBucketEntry.liveEntry);
break;
case DEADENTRY:
LedgerKey.encode(stream, encodedBucketEntry.deadEntry);
break;
}
}
public static BucketEntry decode(XdrDataInputStream stream) throws IOException {
BucketEntry decodedBucketEntry = new BucketEntry();
switch (decodedBucketEntry.getDiscriminant()) {
case LIVEENTRY:
decodedBucketEntry.liveEntry = LedgerEntry.decode(stream);
break;
case DEADENTRY:
decodedBucketEntry.deadEntry = LedgerKey.decode(stream);
break;
}
return decodedBucketEntry;
}
}