git.iko.soy/opencode-android
on master help sign in
86 lines 3.4 kB history raw
1package soy.iko.opencode.shared;
4public final class ToolView {
5 public final String name;
6 public final String status;
7 public final java.util.Optional<String> title;
9 public ToolView(String name, String status, java.util.Optional<String> title) {
10 java.util.Objects.requireNonNull(name, "name must not be null");
11 java.util.Objects.requireNonNull(status, "status must not be null");
12 java.util.Objects.requireNonNull(title, "title must not be null");
13 this.name = name;
14 this.status = status;
15 this.title = title;
16 }
18 public void serialize(com.novi.serde.Serializer serializer) throws com.novi.serde.SerializationError {
19 serializer.increase_container_depth();
20 serializer.serialize_str(name);
21 serializer.serialize_str(status);
22 TraitHelpers.serialize_option_str(title, serializer);
23 serializer.decrease_container_depth();
24 }
26 public byte[] bincodeSerialize() throws com.novi.serde.SerializationError {
27 com.novi.serde.Serializer serializer = new com.novi.bincode.BincodeSerializer();
28 serialize(serializer);
29 return serializer.get_bytes();
30 }
32 public static ToolView deserialize(com.novi.serde.Deserializer deserializer) throws com.novi.serde.DeserializationError {
33 deserializer.increase_container_depth();
34 Builder builder = new Builder();
35 builder.name = deserializer.deserialize_str();
36 builder.status = deserializer.deserialize_str();
37 builder.title = TraitHelpers.deserialize_option_str(deserializer);
38 deserializer.decrease_container_depth();
39 return builder.build();
40 }
42 public static ToolView bincodeDeserialize(byte[] input) throws com.novi.serde.DeserializationError {
43 if (input == null) {
44 throw new com.novi.serde.DeserializationError("Cannot deserialize null array");
45 }
46 com.novi.serde.Deserializer deserializer = new com.novi.bincode.BincodeDeserializer(input);
47 ToolView value = deserialize(deserializer);
48 if (deserializer.get_buffer_offset() < input.length) {
49 throw new com.novi.serde.DeserializationError("Some input bytes were not read");
50 }
51 return value;
52 }
54 public boolean equals(Object obj) {
55 if (this == obj) return true;
56 if (obj == null) return false;
57 if (getClass() != obj.getClass()) return false;
58 ToolView other = (ToolView) obj;
59 if (!java.util.Objects.equals(this.name, other.name)) { return false; }
60 if (!java.util.Objects.equals(this.status, other.status)) { return false; }
61 if (!java.util.Objects.equals(this.title, other.title)) { return false; }
62 return true;
63 }
65 public int hashCode() {
66 int value = 7;
67 value = 31 * value + (this.name != null ? this.name.hashCode() : 0);
68 value = 31 * value + (this.status != null ? this.status.hashCode() : 0);
69 value = 31 * value + (this.title != null ? this.title.hashCode() : 0);
70 return value;
71 }
73 public static final class Builder {
74 public String name;
75 public String status;
76 public java.util.Optional<String> title;
78 public ToolView build() {
79 return new ToolView(
80 name,
81 status,
82 title
83 );
84 }
85 }