-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathMoveLocation.java
95 lines (84 loc) · 4.14 KB
/
MoveLocation.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
87
88
89
90
91
92
93
94
95
package io.sui.bcsgen;
public final class MoveLocation {
public final ModuleId module;
public final @com.novi.serde.Unsigned Short function;
public final @com.novi.serde.Unsigned Short instruction;
public final java.util.Optional<String> function_name;
public MoveLocation(ModuleId module, @com.novi.serde.Unsigned Short function, @com.novi.serde.Unsigned Short instruction, java.util.Optional<String> function_name) {
java.util.Objects.requireNonNull(module, "module must not be null");
java.util.Objects.requireNonNull(function, "function must not be null");
java.util.Objects.requireNonNull(instruction, "instruction must not be null");
java.util.Objects.requireNonNull(function_name, "function_name must not be null");
this.module = module;
this.function = function;
this.instruction = instruction;
this.function_name = function_name;
}
public void serialize(com.novi.serde.Serializer serializer) throws com.novi.serde.SerializationError {
serializer.increase_container_depth();
module.serialize(serializer);
serializer.serialize_u16(function);
serializer.serialize_u16(instruction);
TraitHelpers.serialize_option_str(function_name, 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 MoveLocation deserialize(com.novi.serde.Deserializer deserializer) throws com.novi.serde.DeserializationError {
deserializer.increase_container_depth();
Builder builder = new Builder();
builder.module = ModuleId.deserialize(deserializer);
builder.function = deserializer.deserialize_u16();
builder.instruction = deserializer.deserialize_u16();
builder.function_name = TraitHelpers.deserialize_option_str(deserializer);
deserializer.decrease_container_depth();
return builder.build();
}
public static MoveLocation 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);
MoveLocation 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;
MoveLocation other = (MoveLocation) obj;
if (!java.util.Objects.equals(this.module, other.module)) { return false; }
if (!java.util.Objects.equals(this.function, other.function)) { return false; }
if (!java.util.Objects.equals(this.instruction, other.instruction)) { return false; }
if (!java.util.Objects.equals(this.function_name, other.function_name)) { return false; }
return true;
}
public int hashCode() {
int value = 7;
value = 31 * value + (this.module != null ? this.module.hashCode() : 0);
value = 31 * value + (this.function != null ? this.function.hashCode() : 0);
value = 31 * value + (this.instruction != null ? this.instruction.hashCode() : 0);
value = 31 * value + (this.function_name != null ? this.function_name.hashCode() : 0);
return value;
}
public static final class Builder {
public ModuleId module;
public @com.novi.serde.Unsigned Short function;
public @com.novi.serde.Unsigned Short instruction;
public java.util.Optional<String> function_name;
public MoveLocation build() {
return new MoveLocation(
module,
function,
instruction,
function_name
);
}
}
}