public OperationRequest deserialize(JsonElement json, Type type, JsonDeserializationContext ctx)
throws JsonParseException {
JsonObject jsonObject = json.getAsJsonObject();
JsonObject parameters = jsonObject.getAsJsonObject(RequestProperty.PARAMS.key());
OperationRequest request = new OperationRequest(
jsonObject.get(RequestProperty.METHOD.key()).getAsString(),
jsonObject.get(RequestProperty.ID.key()).getAsString(),
getPropertyAsStringThenRemove(parameters, ParamsProperty.WAVE_ID),
getPropertyAsStringThenRemove(parameters, ParamsProperty.WAVELET_ID),
getPropertyAsStringThenRemove(parameters, ParamsProperty.BLIP_ID));
for (Entry<String, JsonElement> parameter : parameters.entrySet()) {
ParamsProperty parameterType = ParamsProperty.fromKey(parameter.getKey());
if (parameterType != null) {
Object object;
if (parameterType == ParamsProperty.RAW_DELTAS) {
object = ctx.deserialize(parameter.getValue(), GsonFactory.RAW_DELTAS_TYPE);
} else {
object = ctx.deserialize(parameter.getValue(), parameterType.clazz());
}
request.addParameter(Parameter.of(parameterType, object));
}
}
return request;
}