Collect imports for a union and its cases.
(
self,
union: Union,
imports: Set[str],
parent_stack: Optional[List[Message]] = None,
)
| 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.""" |
no test coverage detected