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

Method get_integer_annotation

compiler/fory_compiler/generators/java.py:1624–1657  ·  view source on GitHub ↗

Return integer encoding annotation for a field type.

(self, field_type: FieldType)

Source from the content-addressed store, hash-verified

1622 imports.add("org.apache.fory.config.Int64Encoding")
1623
1624 def get_integer_annotation(self, field_type: FieldType) -> Optional[str]:
1625 """Return integer encoding annotation for a field type."""
1626 if not isinstance(field_type, PrimitiveType):
1627 return None
1628 kind = field_type.kind
1629 if kind == PrimitiveKind.INT32 and field_type.encoding_modifier == "fixed":
1630 return "@Int32Type(encoding = Int32Encoding.FIXED)"
1631 if kind == PrimitiveKind.INT32 and field_type.encoding_modifier == "varint":
1632 return "@Int32Type(encoding = Int32Encoding.VARINT)"
1633 if kind == PrimitiveKind.INT64 and field_type.encoding_modifier == "fixed":
1634 return "@Int64Type(encoding = Int64Encoding.FIXED)"
1635 if kind == PrimitiveKind.INT64 and field_type.encoding_modifier == "varint":
1636 return "@Int64Type(encoding = Int64Encoding.VARINT)"
1637 if kind == PrimitiveKind.INT64 and field_type.encoding_modifier == "tagged":
1638 return "@Int64Type(encoding = Int64Encoding.TAGGED)"
1639 if kind == PrimitiveKind.UINT8:
1640 return "@UInt8Type"
1641 if kind == PrimitiveKind.UINT16:
1642 return "@UInt16Type"
1643 if kind == PrimitiveKind.UINT32 and field_type.encoding_modifier == "fixed":
1644 return "@UInt32Type(encoding = Int32Encoding.FIXED)"
1645 if kind == PrimitiveKind.UINT32:
1646 if field_type.encoding_modifier == "varint":
1647 return "@UInt32Type(encoding = Int32Encoding.VARINT)"
1648 return "@UInt32Type"
1649 if kind == PrimitiveKind.UINT64 and field_type.encoding_modifier == "fixed":
1650 return "@UInt64Type(encoding = Int64Encoding.FIXED)"
1651 if kind == PrimitiveKind.UINT64 and field_type.encoding_modifier == "varint":
1652 return "@UInt64Type(encoding = Int64Encoding.VARINT)"
1653 if kind == PrimitiveKind.UINT64 and field_type.encoding_modifier == "tagged":
1654 return "@UInt64Type(encoding = Int64Encoding.TAGGED)"
1655 if kind == PrimitiveKind.UINT64:
1656 return "@UInt64Type"
1657 return None
1658
1659 def get_primitive_list_annotation(self, field: Field) -> Optional[str]:
1660 """Return field annotation for specialized primitive-list element metadata."""

Callers 3

generate_fieldMethod · 0.95
generate_typeMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected