| 53 | } |
| 54 | |
| 55 | absl::optional<LegacyMapValue> AsLegacyMapValue(const Value& value) { |
| 56 | if (IsLegacyMapValue(value)) { |
| 57 | return GetLegacyMapValue(value); |
| 58 | } |
| 59 | if (auto custom_map_value = value.AsCustomMap(); custom_map_value) { |
| 60 | NativeTypeId native_type_id = NativeTypeId::Of(*custom_map_value); |
| 61 | if (native_type_id == NativeTypeId::For<CompatMapValue>()) { |
| 62 | return LegacyMapValue( |
| 63 | static_cast<const google::api::expr::runtime::CelMap*>( |
| 64 | cel::internal::down_cast<const CompatMapValue*>( |
| 65 | custom_map_value->interface()))); |
| 66 | } else if (native_type_id == NativeTypeId::For<MutableCompatMapValue>()) { |
| 67 | return LegacyMapValue( |
| 68 | static_cast<const google::api::expr::runtime::CelMap*>( |
| 69 | cel::internal::down_cast<const MutableCompatMapValue*>( |
| 70 | custom_map_value->interface()))); |
| 71 | } |
| 72 | } |
| 73 | return absl::nullopt; |
| 74 | } |
| 75 | |
| 76 | } // namespace cel::common_internal |
no test coverage detected