Initial Python rewrite

This commit is contained in:
2026-02-19 17:50:14 +00:00
parent da95a64fb7
commit faa04a0d01
158 changed files with 5122 additions and 1144 deletions

View File

@@ -0,0 +1,35 @@
/*
* Copyright 2025 Google. This software is provided as-is, without warranty or representation for any use or purpose.
* Your use of it is subject to your agreement with Google.
*/
package com.example.util;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.google.cloud.Timestamp;
import java.io.IOException;
/**
* Custom Jackson Serializer for com.google.cloud.Timestamp.
* This is crucial for ObjectMapper.convertValue to correctly handle Timestamp objects
* when they are encountered in a Map<String, Object> and need to be internally
* serialized before deserialization into a DTO. It converts Timestamp into a
* simple JSON object with "seconds" and "nanos" fields.
*/
public class FirestoreTimestampSerializer extends JsonSerializer<Timestamp> {
@Override
public void serialize(Timestamp value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
if (value == null) {
gen.writeNull();
} else {
// Write Timestamp as a JSON object with seconds and nanos
gen.writeStartObject();
gen.writeNumberField("seconds", value.getSeconds());
gen.writeNumberField("nanos", value.getNanos());
gen.writeEndObject();
}
}
}