git.iko.soy/opencode-android
on master help sign in
131 lines 5.9 kB history raw
1package soy.iko.opencode.shared;
4public final class MessageView {
5 public final String id;
6 public final String role;
7 public final String text;
8 public final java.util.Optional<String> reasoning;
9 public final java.util.List<ToolView> tools;
10 public final @com.novi.serde.Unsigned Long time;
11 public final MessageStatus status;
12 public final Boolean streaming;
14 public MessageView(String id, String role, String text, java.util.Optional<String> reasoning, java.util.List<ToolView> tools, @com.novi.serde.Unsigned Long time, MessageStatus status, Boolean streaming) {
15 java.util.Objects.requireNonNull(id, "id must not be null");
16 java.util.Objects.requireNonNull(role, "role must not be null");
17 java.util.Objects.requireNonNull(text, "text must not be null");
18 java.util.Objects.requireNonNull(reasoning, "reasoning must not be null");
19 java.util.Objects.requireNonNull(tools, "tools must not be null");
20 java.util.Objects.requireNonNull(time, "time must not be null");
21 java.util.Objects.requireNonNull(status, "status must not be null");
22 java.util.Objects.requireNonNull(streaming, "streaming must not be null");
23 this.id = id;
24 this.role = role;
25 this.text = text;
26 this.reasoning = reasoning;
27 this.tools = tools;
28 this.time = time;
29 this.status = status;
30 this.streaming = streaming;
31 }
33 public void serialize(com.novi.serde.Serializer serializer) throws com.novi.serde.SerializationError {
34 serializer.increase_container_depth();
35 serializer.serialize_str(id);
36 serializer.serialize_str(role);
37 serializer.serialize_str(text);
38 TraitHelpers.serialize_option_str(reasoning, serializer);
39 TraitHelpers.serialize_vector_ToolView(tools, serializer);
40 serializer.serialize_u64(time);
41 status.serialize(serializer);
42 serializer.serialize_bool(streaming);
43 serializer.decrease_container_depth();
44 }
46 public byte[] bincodeSerialize() throws com.novi.serde.SerializationError {
47 com.novi.serde.Serializer serializer = new com.novi.bincode.BincodeSerializer();
48 serialize(serializer);
49 return serializer.get_bytes();
50 }
52 public static MessageView deserialize(com.novi.serde.Deserializer deserializer) throws com.novi.serde.DeserializationError {
53 deserializer.increase_container_depth();
54 Builder builder = new Builder();
55 builder.id = deserializer.deserialize_str();
56 builder.role = deserializer.deserialize_str();
57 builder.text = deserializer.deserialize_str();
58 builder.reasoning = TraitHelpers.deserialize_option_str(deserializer);
59 builder.tools = TraitHelpers.deserialize_vector_ToolView(deserializer);
60 builder.time = deserializer.deserialize_u64();
61 builder.status = MessageStatus.deserialize(deserializer);
62 builder.streaming = deserializer.deserialize_bool();
63 deserializer.decrease_container_depth();
64 return builder.build();
65 }
67 public static MessageView bincodeDeserialize(byte[] input) throws com.novi.serde.DeserializationError {
68 if (input == null) {
69 throw new com.novi.serde.DeserializationError("Cannot deserialize null array");
70 }
71 com.novi.serde.Deserializer deserializer = new com.novi.bincode.BincodeDeserializer(input);
72 MessageView value = deserialize(deserializer);
73 if (deserializer.get_buffer_offset() < input.length) {
74 throw new com.novi.serde.DeserializationError("Some input bytes were not read");
75 }
76 return value;
77 }
79 public boolean equals(Object obj) {
80 if (this == obj) return true;
81 if (obj == null) return false;
82 if (getClass() != obj.getClass()) return false;
83 MessageView other = (MessageView) obj;
84 if (!java.util.Objects.equals(this.id, other.id)) { return false; }
85 if (!java.util.Objects.equals(this.role, other.role)) { return false; }
86 if (!java.util.Objects.equals(this.text, other.text)) { return false; }
87 if (!java.util.Objects.equals(this.reasoning, other.reasoning)) { return false; }
88 if (!java.util.Objects.equals(this.tools, other.tools)) { return false; }
89 if (!java.util.Objects.equals(this.time, other.time)) { return false; }
90 if (!java.util.Objects.equals(this.status, other.status)) { return false; }
91 if (!java.util.Objects.equals(this.streaming, other.streaming)) { return false; }
92 return true;
93 }
95 public int hashCode() {
96 int value = 7;
97 value = 31 * value + (this.id != null ? this.id.hashCode() : 0);
98 value = 31 * value + (this.role != null ? this.role.hashCode() : 0);
99 value = 31 * value + (this.text != null ? this.text.hashCode() : 0);
100 value = 31 * value + (this.reasoning != null ? this.reasoning.hashCode() : 0);
101 value = 31 * value + (this.tools != null ? this.tools.hashCode() : 0);
102 value = 31 * value + (this.time != null ? this.time.hashCode() : 0);
103 value = 31 * value + (this.status != null ? this.status.hashCode() : 0);
104 value = 31 * value + (this.streaming != null ? this.streaming.hashCode() : 0);
105 return value;
106 }
108 public static final class Builder {
109 public String id;
110 public String role;
111 public String text;
112 public java.util.Optional<String> reasoning;
113 public java.util.List<ToolView> tools;
114 public @com.novi.serde.Unsigned Long time;
115 public MessageStatus status;
116 public Boolean streaming;
118 public MessageView build() {
119 return new MessageView(
120 id,
121 role,
122 text,
123 reasoning,
124 tools,
125 time,
126 status,
127 streaming
128 );
129 }
130 }