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

Method collect_union_imports

compiler/fory_compiler/generators/java.py:689–711  ·  view source on GitHub ↗

Collect imports for a union and its cases.

(
        self,
        union: Union,
        imports: Set[str],
        parent_stack: Optional[List[Message]] = None,
    )

Source from the content-addressed store, hash-verified

687 imports.add("org.apache.fory.annotation.ForyEnumId")
688
689 def collect_union_imports(
690 self,
691 union: Union,
692 imports: Set[str],
693 parent_stack: Optional[List[Message]] = None,
694 ):
695 """Collect imports for a union and its cases."""
696 imports.add("org.apache.fory.type.union.Union")
697 imports.add("org.apache.fory.type.Types")
698 imports.add("java.util.Objects")
699 if any(
700 self.field_type_contains_array(field.field_type) for field in union.fields
701 ):
702 imports.add("java.util.Arrays")
703 for field in union.fields:
704 self.collect_type_imports(
705 field.field_type,
706 imports,
707 field.element_optional,
708 field.element_ref,
709 field,
710 parent_stack=parent_stack,
711 )
712
713 def has_array_field_recursive(self, message: Message) -> bool:
714 """Check if message or any nested message has array fields."""

Callers 3

generate_union_fileMethod · 0.95

Calls 4

collect_type_importsMethod · 0.95
anyFunction · 0.85
addMethod · 0.65

Tested by

no test coverage detected