Source:
public IOpportunityActivity deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException { if (jsonElement instanceof JsonObject) { JsonObject element = (JsonObject) jsonElement; JsonObject links = element.getAsJsonObject(LINKS); if (links != null) { JsonObject self = links.getAsJsonObject(SELF); if (self != null) { JsonPrimitive clazz = self.getAsJsonPrimitive(CLASS); if (HISTORY.equalsIgnoreCase(clazz.getAsString())) { return gson.fromJson(jsonElement, OpportunitySystemEvent.class); } else if (OPPORTUNITY_ACTIVITY.equalsIgnoreCase(clazz.getAsString()) || OPPORTUNITY_ATTACHMENT.equalsIgnoreCase(clazz.getAsString())) { JsonPrimitive activityType = element.getAsJsonPrimitive(TYPE); if (OpportunityActivityTypes.CALL.equalsIgnoreCase(activityType.getAsString())) { return gson.fromJson(jsonElement, OpportunityCall.class); } else if (OpportunityActivityTypes.EMAIL.equalsIgnoreCase(activityType.getAsString())) { return gson.fromJson(jsonElement, OpportunityEmail.class); } else if (OpportunityActivityTypes.EVENT.equalsIgnoreCase(activityType.getAsString())) { return gson.fromJson(jsonElement, OpportunityEvent.class); } else if (OpportunityActivityTypes.NOTE.equalsIgnoreCase(activityType.getAsString())) { return gson.fromJson(jsonElement, OpportunityNote.class); } else if (OpportunityActivityTypes.TASK.equalsIgnoreCase(activityType.getAsString())) { return gson.fromJson(jsonElement, OpportunityTask.class); } else if (OpportunityActivityTypes.ATTACHMENT.equalsIgnoreCase(activityType.getAsString())) { return gson.fromJson(jsonElement, OpportunityAttachment.class); } } } } } return null; }

Target:
public IOpportunityActivity deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException { if (jsonElement instanceof JsonObject) { JsonObject element = (JsonObject) jsonElement; JsonObject links = element.getAsJsonObject(LINKS); if (links != null) { JsonObject self = links.getAsJsonObject(SELF); if (self != null) { JsonPrimitive clazz = self.getAsJsonPrimitive(CLASS); if (HISTORY.equalsIgnoreCase(clazz.getAsString())) { return gson.fromJson(jsonElement, OpportunitySystemEvent.class); } else { JsonPrimitive activityType = element.getAsJsonPrimitive(TYPE); if (OpportunityEventType.CALL.name().equalsIgnoreCase(activityType.getAsString())) { return gson.fromJson(jsonElement, OpportunityCall.class); } else if (OpportunityEventType.EMAIL.name().equalsIgnoreCase(activityType.getAsString())) { return gson.fromJson(jsonElement, OpportunityEmail.class); } else if (OpportunityEventType.EVENT.name().equalsIgnoreCase(activityType.getAsString())) { return gson.fromJson(jsonElement, OpportunityEvent.class); } else if (OpportunityEventType.NOTE.name().equalsIgnoreCase(activityType.getAsString())) { return gson.fromJson(jsonElement, OpportunityNote.class); } else if (OpportunityEventType.TASK.name().equalsIgnoreCase(activityType.getAsString())) { return gson.fromJson(jsonElement, OpportunityTask.class); } else if (OPPORTUNITY_ATTACHMENT.equalsIgnoreCase(activityType.getAsString())) { return gson.fromJson(jsonElement, OpportunityAttachment.class); } } } } } return null; }