-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathConsensusCommitPrologue.java
86 lines (75 loc) · 3.69 KB
/
ConsensusCommitPrologue.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
package io.sui.bcsgen;
public final class ConsensusCommitPrologue {
public final @com.novi.serde.Unsigned Long epoch;
public final @com.novi.serde.Unsigned Long round;
public final @com.novi.serde.Unsigned Long commit_timestamp_ms;
public ConsensusCommitPrologue(@com.novi.serde.Unsigned Long epoch, @com.novi.serde.Unsigned Long round, @com.novi.serde.Unsigned Long commit_timestamp_ms) {
java.util.Objects.requireNonNull(epoch, "epoch must not be null");
java.util.Objects.requireNonNull(round, "round must not be null");
java.util.Objects.requireNonNull(commit_timestamp_ms, "commit_timestamp_ms must not be null");
this.epoch = epoch;
this.round = round;
this.commit_timestamp_ms = commit_timestamp_ms;
}
public void serialize(com.novi.serde.Serializer serializer) throws com.novi.serde.SerializationError {
serializer.increase_container_depth();
serializer.serialize_u64(epoch);
serializer.serialize_u64(round);
serializer.serialize_u64(commit_timestamp_ms);
serializer.decrease_container_depth();
}
public byte[] bcsSerialize() throws com.novi.serde.SerializationError {
com.novi.serde.Serializer serializer = new com.novi.bcs.BcsSerializer();
serialize(serializer);
return serializer.get_bytes();
}
public static ConsensusCommitPrologue deserialize(com.novi.serde.Deserializer deserializer) throws com.novi.serde.DeserializationError {
deserializer.increase_container_depth();
Builder builder = new Builder();
builder.epoch = deserializer.deserialize_u64();
builder.round = deserializer.deserialize_u64();
builder.commit_timestamp_ms = deserializer.deserialize_u64();
deserializer.decrease_container_depth();
return builder.build();
}
public static ConsensusCommitPrologue bcsDeserialize(byte[] input) throws com.novi.serde.DeserializationError {
if (input == null) {
throw new com.novi.serde.DeserializationError("Cannot deserialize null array");
}
com.novi.serde.Deserializer deserializer = new com.novi.bcs.BcsDeserializer(input);
ConsensusCommitPrologue value = deserialize(deserializer);
if (deserializer.get_buffer_offset() < input.length) {
throw new com.novi.serde.DeserializationError("Some input bytes were not read");
}
return value;
}
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
ConsensusCommitPrologue other = (ConsensusCommitPrologue) obj;
if (!java.util.Objects.equals(this.epoch, other.epoch)) { return false; }
if (!java.util.Objects.equals(this.round, other.round)) { return false; }
if (!java.util.Objects.equals(this.commit_timestamp_ms, other.commit_timestamp_ms)) { return false; }
return true;
}
public int hashCode() {
int value = 7;
value = 31 * value + (this.epoch != null ? this.epoch.hashCode() : 0);
value = 31 * value + (this.round != null ? this.round.hashCode() : 0);
value = 31 * value + (this.commit_timestamp_ms != null ? this.commit_timestamp_ms.hashCode() : 0);
return value;
}
public static final class Builder {
public @com.novi.serde.Unsigned Long epoch;
public @com.novi.serde.Unsigned Long round;
public @com.novi.serde.Unsigned Long commit_timestamp_ms;
public ConsensusCommitPrologue build() {
return new ConsensusCommitPrologue(
epoch,
round,
commit_timestamp_ms
);
}
}
}