-
Notifications
You must be signed in to change notification settings - Fork 11
/
Coin.java
77 lines (66 loc) · 2.66 KB
/
Coin.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
package io.sui.bcsgen;
public final class Coin {
public final UID id;
public final Balance balance;
public Coin(UID id, Balance balance) {
java.util.Objects.requireNonNull(id, "id must not be null");
java.util.Objects.requireNonNull(balance, "balance must not be null");
this.id = id;
this.balance = balance;
}
public void serialize(com.novi.serde.Serializer serializer) throws com.novi.serde.SerializationError {
serializer.increase_container_depth();
id.serialize(serializer);
balance.serialize(serializer);
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 Coin deserialize(com.novi.serde.Deserializer deserializer) throws com.novi.serde.DeserializationError {
deserializer.increase_container_depth();
Builder builder = new Builder();
builder.id = UID.deserialize(deserializer);
builder.balance = Balance.deserialize(deserializer);
deserializer.decrease_container_depth();
return builder.build();
}
public static Coin 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);
Coin 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;
Coin other = (Coin) obj;
if (!java.util.Objects.equals(this.id, other.id)) { return false; }
if (!java.util.Objects.equals(this.balance, other.balance)) { return false; }
return true;
}
public int hashCode() {
int value = 7;
value = 31 * value + (this.id != null ? this.id.hashCode() : 0);
value = 31 * value + (this.balance != null ? this.balance.hashCode() : 0);
return value;
}
public static final class Builder {
public UID id;
public Balance balance;
public Coin build() {
return new Coin(
id,
balance
);
}
}
}