use of com.thebluealliance.androidclient.models.TeamAtEventStatus.TeamAtEventPlayoff in project the-blue-alliance-android by the-blue-alliance.
the class TeamAtEventStatusDeserializer method deserialize.
@Override
public TeamAtEventStatus deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
JsonObject data = json.getAsJsonObject();
TeamAtEventStatus status = new TeamAtEventStatus();
if (!isNull(data.get("alliance"))) {
JsonObject allianceJson = data.getAsJsonObject("alliance");
TeamAtEventStatus.TeamAtEventAlliance alliance = new TeamAtEventStatus.TeamAtEventAlliance();
alliance.setName(allianceJson.get("name").getAsString());
alliance.setNumber(allianceJson.get("number").getAsInt());
alliance.setPick(allianceJson.get("pick").getAsInt());
if (!isNull(allianceJson.get("backup"))) {
alliance.setBackup(context.deserialize(allianceJson.get("backup"), IAllianceBackup.class));
}
status.setAlliance(alliance);
}
if (!isNull(data.get("alliance_status_str"))) {
status.setAllianceStatusStr(data.get("alliance_status_str").getAsString());
}
if (!isNull(data.get("overall_status_str"))) {
status.setOverallStatusStr(data.get("overall_status_str").getAsString());
}
if (!isNull(data.get("playoff_status_str"))) {
status.setPlayoffStatusStr(data.get("playoff_status_str").getAsString());
}
if (!isNull(data.get("playoff"))) {
JsonObject playoffJson = data.getAsJsonObject("playoff");
TeamAtEventPlayoff playoff = context.deserialize(playoffJson, TeamAtEventPlayoff.class);
status.setPlayoff(playoff);
}
if (!isNull(data.get("qual"))) {
JsonObject qualJson = data.getAsJsonObject("qual");
TeamAtEventStatus.TeamAtEventQual qual = new TeamAtEventStatus.TeamAtEventQual();
RankingItem teamRank = context.deserialize(qualJson.get("ranking"), RankingItem.class);
List<IRankingSortOrder> sortOrders = context.deserialize(qualJson.get("sort_order_info"), new TypeToken<List<IRankingSortOrder>>() {
}.getType());
qual.setRanking(teamRank);
qual.setSortOrderInfo(sortOrders);
qual.setNumTeams(qualJson.get("num_teams").getAsInt());
qual.setStatus(qualJson.get("status").getAsString());
status.setQual(qual);
}
return status;
}
Aggregations