Collect imports for primitive array type annotations.
(self, field: Field, imports: Set[str])
| 1560 | imports.add("org.apache.fory.annotation.BFloat16Type") |
| 1561 | |
| 1562 | def collect_array_imports(self, field: Field, imports: Set[str]) -> None: |
| 1563 | """Collect imports for primitive array type annotations.""" |
| 1564 | if isinstance(field.field_type, ArrayType): |
| 1565 | element_type = field.field_type.element_type |
| 1566 | elif isinstance(field.field_type, ListType): |
| 1567 | if not self.java_array(field): |
| 1568 | return |
| 1569 | if field.element_optional or field.element_ref: |
| 1570 | return |
| 1571 | element_type = field.field_type.element_type |
| 1572 | else: |
| 1573 | return |
| 1574 | if not isinstance(element_type, PrimitiveType): |
| 1575 | return |
| 1576 | kind = element_type.kind |
| 1577 | if isinstance(field.field_type, ArrayType) and not self.java_array(field): |
| 1578 | if kind in (PrimitiveKind.FLOAT16, PrimitiveKind.BFLOAT16): |
| 1579 | return |
| 1580 | if isinstance(field.field_type, ListType) and not self.java_array(field): |
| 1581 | if kind in (PrimitiveKind.FLOAT16, PrimitiveKind.BFLOAT16): |
| 1582 | return |
| 1583 | if kind == PrimitiveKind.INT8: |
| 1584 | imports.add("org.apache.fory.annotation.Int8Type") |
| 1585 | elif kind == PrimitiveKind.UINT8: |
| 1586 | imports.add("org.apache.fory.annotation.UInt8Type") |
| 1587 | elif kind == PrimitiveKind.UINT16: |
| 1588 | imports.add("org.apache.fory.annotation.UInt16Type") |
| 1589 | elif kind == PrimitiveKind.UINT32: |
| 1590 | imports.add("org.apache.fory.annotation.UInt32Type") |
| 1591 | elif kind == PrimitiveKind.UINT64: |
| 1592 | imports.add("org.apache.fory.annotation.UInt64Type") |
| 1593 | elif kind == PrimitiveKind.FLOAT16: |
| 1594 | imports.add("org.apache.fory.annotation.Float16Type") |
| 1595 | elif kind == PrimitiveKind.BFLOAT16: |
| 1596 | imports.add("org.apache.fory.annotation.BFloat16Type") |
| 1597 | |
| 1598 | def collect_integer_imports(self, field_type: FieldType, imports: Set[str]) -> None: |
| 1599 | """Collect imports for integer encoding annotations.""" |
no test coverage detected