MCPcopy Create free account
hub / github.com/apache/fory / generate_bytes_methods

Method generate_bytes_methods

compiler/fory_compiler/generators/java.py:263–276  ·  view source on GitHub ↗
(self, class_name: str)

Source from the content-addressed store, hash-verified

261 return ordered
262
263 def generate_bytes_methods(self, class_name: str) -> List[str]:
264 reg_class = self.get_module_class_name()
265 lines = []
266 lines.append("public byte[] toBytes() {")
267 lines.append(f" return {reg_class}.getFory().serialize(this);")
268 lines.append("}")
269 lines.append("")
270 lines.append(f"public static {class_name} fromBytes(byte[] bytes) {{")
271 lines.append(
272 f" return {reg_class}.getFory().deserialize(bytes, {class_name}.class);"
273 )
274 lines.append("}")
275 lines.append("")
276 return lines
277
278 # Mapping from FDL primitive types to Java types
279 PRIMITIVE_MAP = {

Callers 3

generate_message_fileMethod · 0.95
generate_union_classMethod · 0.95

Calls 2

get_module_class_nameMethod · 0.95
appendMethod · 0.45

Tested by

no test coverage detected