@Override public JsonElement serialize(PartitionKey partitionKey, Type type, JsonSerializationContext jsonSerializationContext) { JsonObject jsonObj = new JsonObject(); for (Map.Entry<String, Comparable> entry : partitionKey.getFields().entrySet()) { jsonObj.add(entry.getKey(), serializeComparable(entry.getValue(), jsonSerializationContext)); } return jsonObj; } }
@Override public PartitionKey deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException { JsonObject jsonObject = jsonElement.getAsJsonObject(); PartitionKey.Builder builder = PartitionKey.builder(); for (Map.Entry<String, JsonElement> entry : jsonObject.entrySet()) { JsonArray jsonArray = entry.getValue().getAsJsonArray(); builder.addField(entry.getKey(), deserializeComparable(jsonArray, jsonDeserializationContext)); } return builder.build(); }