Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   package com.robrua.orianna.api;
   
   import java.time.Duration;
   import java.time.ZoneOffset;
   import java.util.ArrayList;
   import java.util.Collections;
  import java.util.HashMap;
  import java.util.List;
  import java.util.Map;
  
  
Used to convert the responses from the JSONRiotAPI to the Orianna typesystem.

Author(s):
Rob Rua (FatalElement - NA) (robrua@alumni.cmu.edu)
 
 public class JSONConverter {
     private static Integer convertInteger(final Object object) {
         final Long longVersion = (Long)object;
         if(longVersion == null) {
             return null;
         }
         return longVersion.intValue();
     }
 
     private static LocalDateTime getDateTime(final JSONObject objectfinal String key) {
         final Long epoch = (Long)object.get(key);
         if(epoch == null) {
             return null;
         }
         return LocalDateTime.ofEpochSecond(epoch / 1000, 0, .);
     }
 
     private static List<DoublegetDoubleList(final JSONArray list) {
         return getList(listd -> (Double)d);
     }
 
     private static List<DoublegetDoubleList(final JSONObject objectfinal String key) {
         return getList(objectkeyd -> (Double)d);
     }
 
     private static Duration getDuration(final JSONObject objectfinal String keyfinal TemporalUnit unit) {
         final Long amt = (Long)object.get(key);
         if(amt == null) {
             return null;
         }
         return Duration.of(amtunit);
     }
 
     private static Integer getInteger(final JSONObject objectfinal String key) {
         return convertInteger(object.get(key));
     }
 
     private static List<IntegergetIntegerList(final JSONArray list) {
         return getList(list, JSONConverter::convertInteger);
     }
 
     private static List<IntegergetIntegerList(final JSONObject objectfinal String key) {
         return getList(objectkey, JSONConverter::convertInteger);
     }
 
     protected static <T> List<T> getList(final JSONArray listfinal Function<Object, T> mapper) {
         return getList(listmappernull);
     }
 
     protected static <T> List<T> getList(final JSONArray listfinal Function<Object, T> mapperfinal Comparator<? super T> sorter) {
         if(list == null) {
             return null;
         }
 
         final List<T> result = new ArrayList<T>(list.size());
         for(final Object obj : list) {
             final T item = mapper.apply(obj);
             result.add(item);
         }
 
         if(sorter != null) {
             result.sort(sorter);
         }
 
         return Collections.unmodifiableList(result);
     }
 
     protected static <T> List<T> getList(final JSONObject objectfinal String keyfinal Function<Object, T> mapper) {
         return getList(objectkeymappernull);
     }
 
     protected static <T> List<T> getList(final JSONObject objectfinal String keyfinal Function<Object, T> mapperfinal Comparator<? super T> sorter) {
         final JSONArray list = (JSONArray)object.get(key);
         if(list == null) {
             return null;
         }
 
         return getList(listmappersorter);
     }
 
     protected static <T> List<T> getListFromMap(final JSONObject mapfinal Function<Object, T> mapper) {
         return getListFromMap(mapmappernull);
     }
 
     protected static <T> List<T> getListFromMap(final JSONObject mapfinal Function<Object, T> mapperfinal Comparator<? super T> sorter) {
         final List<T> result = new ArrayList<T>(map.size());
         for(final Object obj : map.values()) {
             final T item = mapper.apply(obj);
             result.add(item);
         }
 
         if(sorter != null) {
             result.sort(sorter);
         }
 
         return Collections.unmodifiableList(result);
     }
 
     protected static <T> List<T> getListFromMap(final JSONObject objectfinal String keyfinal Function<Object, T> mapper) {
         return getListFromMap(objectkeymappernull);
     }
 
     protected static <T> List<T> getListFromMap(final JSONObject objectfinal String keyfinal Function<Object, T> mapperfinal Comparator<? super T> sorter) {
         final JSONObject map = (JSONObject)object.get(key);
         if(map == null) {
             return null;
         }
 
         return getListFromMap(mapmappersorter);
     }
 
     private static MatchMap getMap(final Integer ID) {
         switch(ID) {
             case 1:
                 return .;
             case 2:
                 return .;
             case 3:
                 return .;
             case 4:
                 return .;
             case 8:
                 return .;
             case 10:
                 return .;
             case 12:
                 return .;
             default:
                 return null;
         }
     }
 
     protected static <T> Map<Object, T> getMapFromList(final JSONArray listfinal Function<Object, T> mapper) {
         final Map<Object, T> result = new HashMap<Object, T>(list.size());
         for(final Object obj : list) {
             final T item = mapper.apply(obj);
             result.put(objitem);
         }
 
         return Collections.unmodifiableMap(result);
     }
 
     protected static <T> Map<Object, T> getMapFromList(final JSONObject objectfinal String keyfinal Function<Object, T> mapper) {
         final JSONArray list = (JSONArray)object.get(key);
         if(list == null) {
             return null;
         }
 
         return getMapFromList(listmapper);
     }
 
     private static Map<StringPatterngetScrapedStatPatterns() {
         final Map<StringPatternpatterns = new HashMap<StringPattern>();
         patterns.put("PercentCooldownMod", Pattern.compile("\\+(\\d+) *% Cooldown Reduction *(<br>|</stats>|</passive>|$)"));
         patterns.put("FlatArmorPenetrationMod", Pattern.compile("\\+(\\d+) *Armor Penetration *(<br>|</stats>|</passive>|$)"));
         patterns.put("PercentArmorPenetrationMod", Pattern.compile("ignores (\\d+)% of the target's Armor"));
         patterns.put("FlatMagicPenetrationMod", Pattern.compile("\\+(\\d+) *Magic Penetration *(<br>|</stats>|</passive>|$)"));
         patterns.put("PercentMagicPenetrationMod", Pattern.compile("ignores (\\d+)% of the target's Magic Resist"));
         patterns.put("FlatGoldPer10Mod", Pattern.compile("\\+(\\d+) *Gold per 10 seconds *(<br>|</stats>|</passive>|$)"));
 
         return patterns;
     }
 
     private static Side getSide(final JSONObject objectfinal String key) {
         final Integer teamId = getInteger(objectkey);
         if(teamId == null) {
             return null;
         }
         else if(teamId == 100) {
             return .;
         }
         else if(teamId == 200) {
             return .;
         }
 
         return null;
     }
 
     private static List<StringgetStringList(final JSONObject objectfinal String key) {
         return getList(objectkeys -> (String)s);
     }
 
     private final RiotAPI API;

    

Parameters:
API a RiotAPI which will be used to replace foreign key ID values with the specified object
 
     public JSONConverter(final RiotAPI API) {
         this. = API;
     }
 
     public AggregatedStats getAggregatedStatsFromJSON(final JSONObject aggregatedStatsInfo) {
         if(aggregatedStatsInfo == null) {
             return null;
         }
 
         final Integer averageAssists = getInteger(aggregatedStatsInfo"averageAssists");
         final Integer averageChampionsKilled = getInteger(aggregatedStatsInfo"averageChampionsKilled");
         final Integer averageCombatPlayerScore = getInteger(aggregatedStatsInfo"averageCombatPlayerScore");
         final Integer averageNodeCapture = getInteger(aggregatedStatsInfo"averageNodeCapture");
         final Integer averageNodeCaptureAssist = getInteger(aggregatedStatsInfo"averageNodeCaptureAssist");
         final Integer averageNodeNeutralize = getInteger(aggregatedStatsInfo"averageNodeNeutralize");
         final Integer averageNodeNeutralizeAssist = getInteger(aggregatedStatsInfo"averageNodeNeutralizeAssist");
         final Integer averageNumDeaths = getInteger(aggregatedStatsInfo"averageNumDeaths");
         final Integer averageObjectivePlayerScore = getInteger(aggregatedStatsInfo"averageObjectivePlayerScore");
         final Integer averageTeamObjective = getInteger(aggregatedStatsInfo"averageTeamObjective");
         final Integer averageTotalPlayerScore = getInteger(aggregatedStatsInfo"averageTotalPlayerScore");
         final Integer botGamesPlayed = getInteger(aggregatedStatsInfo"botGamesPlayed");
         final Integer killingSpree = getInteger(aggregatedStatsInfo"killingSpree");
         final Integer maxAssists = getInteger(aggregatedStatsInfo"maxAssists");
         final Integer maxChampionsKilled = getInteger(aggregatedStatsInfo"maxChampionsKilled");
         final Integer maxCombatPlayerScore = getInteger(aggregatedStatsInfo"maxCombatPlayerScore");
         final Integer maxLargestCriticalStrike = getInteger(aggregatedStatsInfo"maxLargestCriticalStrike");
         final Integer maxLargestKillingSpree = getInteger(aggregatedStatsInfo"maxLargestKillingSpree");
         final Integer maxNodeCapture = getInteger(aggregatedStatsInfo"maxNodeCapture");
         final Integer maxNodeCaputreAssist = getInteger(aggregatedStatsInfo"maxNodeCaputreAssist");
         final Integer maxNodeNeutralize = getInteger(aggregatedStatsInfo"maxNodeNeutralize");
         final Integer maxNodeNeutralizeAssist = getInteger(aggregatedStatsInfo"maxNodeNeutralizeAssist");
         final Integer maxNumDeaths = getInteger(aggregatedStatsInfo"maxNumDeaths");
         final Integer maxObjectivePlayerScore = getInteger(aggregatedStatsInfo"maxObjectivePlayerScore");
         final Integer maxTeamObjective = getInteger(aggregatedStatsInfo"maxTeamObjective");
         final Integer maxTimePlayed = getInteger(aggregatedStatsInfo"maxTimePlayed");
         final Integer maxTimeSpentLiving = getInteger(aggregatedStatsInfo"maxTimeSpentLiving");
         final Integer maxTotalPlayerScore = getInteger(aggregatedStatsInfo"maxTotalPlayerScore");
         final Integer mostChampionKillsPerSession = getInteger(aggregatedStatsInfo"mostChampionKillsPerSession");
         final Integer mostSpellsCast = getInteger(aggregatedStatsInfo"mostSpellsCast");
         final Integer normalGamesPlayed = getInteger(aggregatedStatsInfo"normalGamesPlayed");
         final Integer rankedPremadeGamesPlayed = getInteger(aggregatedStatsInfo"rankedPremadeGamesPlayed");
         final Integer rankedSoloGamesPlayed = getInteger(aggregatedStatsInfo"rankedSoloGamesPlayed");
         final Integer totalAssists = getInteger(aggregatedStatsInfo"totalAssists");
         final Integer totalChampionKills = getInteger(aggregatedStatsInfo"totalChampionKills");
         final Integer totalDamageDealt = getInteger(aggregatedStatsInfo"totalDamageDealt");
         final Integer totalDamageTaken = getInteger(aggregatedStatsInfo"totalDamageTaken");
         final Integer totalDeathsPerSession = getInteger(aggregatedStatsInfo"totalDeathsPerSession");
         final Integer totalDoubleKills = getInteger(aggregatedStatsInfo"totalDoubleKills");
         final Integer totalFirstBlood = getInteger(aggregatedStatsInfo"totalFirstBlood");
         final Integer totalGoldEarned = getInteger(aggregatedStatsInfo"totalGoldEarned");
         final Integer totalHeal = getInteger(aggregatedStatsInfo"totalHeal");
         final Integer totalMagicDamageDealt = getInteger(aggregatedStatsInfo"totalMagicDamageDealt");
         final Integer totalMinionKills = getInteger(aggregatedStatsInfo"totalMinionKills");
         final Integer totalNeutralMinionsKilled = getInteger(aggregatedStatsInfo"totalNeutralMinionsKilled");
         final Integer totalNodeCapture = getInteger(aggregatedStatsInfo"totalNodeCapture");
         final Integer totalNodeNeutralize = getInteger(aggregatedStatsInfo"totalNodeNeutralize");
         final Integer totalPentaKills = getInteger(aggregatedStatsInfo"totalPentaKills");
         final Integer totalPhysicalDamageDealt = getInteger(aggregatedStatsInfo"totalPhysicalDamageDealt");
         final Integer totalQuadraKills = getInteger(aggregatedStatsInfo"totalQuadraKills");
         final Integer totalSessionsLost = getInteger(aggregatedStatsInfo"totalSessionsLost");
         final Integer totalSessionsWon = getInteger(aggregatedStatsInfo"totalSessionsWon");
         final Integer totalTripleKills = getInteger(aggregatedStatsInfo"totalTripleKills");
         final Integer totalTurretsKilled = getInteger(aggregatedStatsInfo"totalTurretsKilled");
         final Integer totalUnrealKills = getInteger(aggregatedStatsInfo"totalUnrealKills");
 
         return new AggregatedStats(averageAssistsaverageChampionsKilledaverageCombatPlayerScoreaverageNodeCaptureaverageNodeCaptureAssist,
                 averageNodeNeutralizeaverageNodeNeutralizeAssistaverageNumDeathsaverageObjectivePlayerScoreaverageTeamObjective,
                 averageTotalPlayerScorebotGamesPlayedkillingSpreemaxAssistsmaxChampionsKilledmaxCombatPlayerScoremaxLargestCriticalStrike,
                 maxLargestKillingSpreemaxNodeCapturemaxNodeCaputreAssistmaxNodeNeutralizemaxNodeNeutralizeAssistmaxNumDeaths,
                 maxObjectivePlayerScoremaxTeamObjectivemaxTimePlayedmaxTimeSpentLivingmaxTotalPlayerScoremostChampionKillsPerSessionmostSpellsCast,
                 normalGamesPlayedrankedPremadeGamesPlayedrankedSoloGamesPlayedtotalAssiststotalChampionKillstotalDamageDealttotalDamageTaken,
                 totalDeathsPerSessiontotalDoubleKillstotalFirstBloodtotalGoldEarnedtotalHealtotalMagicDamageDealttotalMinionKills,
                 totalNeutralMinionsKilledtotalNodeCapturetotalNodeNeutralizetotalPentaKillstotalPhysicalDamageDealttotalQuadraKills,
                 totalSessionsLosttotalSessionsWontotalTripleKillstotalTurretsKilledtotalUnrealKills);
     }
 
     private List<GamePlayergetAllGamePlayersFromJSON(final JSONArray playerList) {
         if(playerList == null) {
             return null;
         }
 
         final List<LongsummonerIDs = getList(playerListm -> (Long)((JSONObject)m).get("summonerId"));
         final List<Summonersummoners = .getSummonersByID(summonerIDs);
         final Map<LongSummonermapping = new HashMap<LongSummoner>();
         for(final Summoner summoner : summoners) {
             mapping.put(summoner.IDsummoner);
         }
 
         return getList(playerListp -> {
             final JSONObject player = (JSONObject)p;
             return getGamePlayerFromJSON(mapping.get(player.get("summonerId")), player);
         });
     }
 
     private List<GamePlayergetAllGamePlayersFromJSON(final Map<LongSummonerplayersfinal JSONArray playerList) {
         if(playerList == null) {
             return null;
         }
 
         return getList(playerListp -> {
             final JSONObject player = (JSONObject)p;
             return getGamePlayerFromJSON(players.get(player.get("summonerId")), player);
         });
     }
 
     protected List<GamegetAllGamesFromJSON(final JSONArray gameList) {
         if(gameList == null) {
             return null;
         }
 
         final Map<ObjectJSONArrayplayerLists = getMapFromList(gameListg -> (JSONArray)((JSONObject)g).get("fellowPlayers"));
         final List<LongsummonerIDs = new ArrayList<Long>();
         final Map<ObjectList<Long>> ownership = new HashMap<ObjectList<Long>>();
         for(final Object obj : playerLists.keySet()) {
             final List<LongIDs = getList(playerLists.get(obj), m -> (Long)((JSONObject)m).get("summonerId"));
             summonerIDs.addAll(IDs);
             ownership.put(objIDs);
         }
 
         final List<Summonersummoners = .getSummonersByID(summonerIDs);
 
         final Map<LongSummonerIDMapping = new HashMap<LongSummoner>();
         for(final Summoner summoner : summoners) {
             IDMapping.put(summoner.IDsummoner);
         }
 
         final Map<ObjectMap<LongSummoner>> mapping = new HashMap<ObjectMap<LongSummoner>>();
         for(final Object obj : ownership.keySet()) {
             final Map<LongSummonersubset = new HashMap<LongSummoner>();
             for(final Long ID : ownership.get(obj)) {
                 subset.put(IDIDMapping.get(ID));
             }
             mapping.put(obj, Collections.unmodifiableMap(subset));
         }
 
         return getList(gameListg -> getGameFromJSON(mapping.get(g), (JSONObject)g));
     }
 
     private List<LeagueEntrygetAllLeagueEntriesFromJSON(final JSONArray leagueEntryList) {
         if(leagueEntryList == null) {
             return null;
         }
 
         final String sampleID = (String)((JSONObject)leagueEntryList.get(0)).get("playerOrTeamId");
         boolean summonerLeague;
         try {
             Long.parseLong(sampleID);
             summonerLeague = true;
         }
         catch(final NumberFormatException e) {
             summonerLeague = false;
         }
 
         if(summonerLeague) {
             final List<LongsummonerIDs = getList(leagueEntryListm -> Long.parseLong((String)((JSONObject)m).get("playerOrTeamId")));
             final List<Summonersummoners = .getSummonersByID(summonerIDs);
 
             final Map<StringSummonermapping = new HashMap<StringSummoner>();
             for(final Summoner summoner : summoners) {
                 mapping.put(Long.toString(summoner.ID), summoner);
             }
 
             return getList(leagueEntryListe -> {
                 final JSONObject entry = (JSONObject)e;
                 return getLeagueEntryFromJSON(mapping.get(entry.get("playerOrTeamId")), entry);
             }, (final LeagueEntry e0final LeagueEntry e1) -> e1.leaguePoints.compareTo(e0.leaguePoints));
         }
         else {
             final List<StringteamIDs = getList(leagueEntryListm -> (String)((JSONObject)m).get("playerOrTeamId"));
             final List<Teamteams = .getTeams(teamIDs);
             final Map<StringTeammapping = new HashMap<StringTeam>();
             for(final Team team : teams) {
                 mapping.put(team.IDteam);
             }
 
             return getList(leagueEntryListe -> {
                 final JSONObject entry = (JSONObject)e;
                 return getLeagueEntryFromJSON(mapping.get(entry.get("playerOrTeamId")), entry);
             });
         }
     }
 
     protected Map<LongList<Team>> getAllSummonersTeamsFromJSON(final JSONObject teamListfinal List<LongIDs) {
         if(teamList == null || IDs.size() != teamList.size()) {
             return null;
         }
 
         final Map<LongMap<JSONObjectList<Long>>> rosterIDs = new HashMap<LongMap<JSONObjectList<Long>>>();
         final List<LongsummonerIDs = new ArrayList<Long>();
         for(final Long ID : IDs) {
             final Map<JSONObjectList<Long>> oneID = new HashMap<JSONObjectList<Long>>();
             final JSONArray teams = (JSONArray)teamList.get(ID.toString());
             for(final Object teamObj : teams) {
                 final JSONObject team = (JSONObject)teamObj;
                 final JSONObject roster = (JSONObject)team.get("roster");
                 final JSONArray memberList = (JSONArray)roster.get("memberList");
                 if(memberList == null) {
                     // Would've already been cached in a non-empty memberList
                     summonerIDs.add((Long)roster.get("ownerId"));
                     oneID.put(teamnew ArrayList<Long>());
                     continue;
                 }
 
                 final List<LongmemberIDs = new ArrayList<Long>();
                 for(final Object memberObj : memberList) {
                     final JSONObject member = (JSONObject)memberObj;
                     final Long memberID = (Long)member.get("playerId");
                     summonerIDs.add(memberID);
                     memberIDs.add(memberID);
                 }
                 oneID.put(teammemberIDs);
             }
             rosterIDs.put(IDoneID);
         }
 
         final List<Summonersummoners = .getSummonersByID(summonerIDs);
 
         final Map<LongSummonermapping = new HashMap<LongSummoner>();
         for(final Summoner summoner : summoners) {
             mapping.put(summoner.IDsummoner);
         }
 
         final Map<LongMap<JSONObjectList<Summoner>>> rosters = new HashMap<LongMap<JSONObjectList<Summoner>>>();
         for(final Long ID : rosterIDs.keySet()) {
             final Map<JSONObjectList<Long>> teamsByID = rosterIDs.get(ID);
             final Map<JSONObjectList<Summoner>> teamsBySummoner = new HashMap<JSONObjectList<Summoner>>();
             for(final JSONObject team : teamsByID.keySet()) {
                 final List<LongrosterByID = teamsByID.get(team);
                 final List<SummonerrosterSummoners = new ArrayList<Summoner>();
                 for(final Long summonerID : rosterByID) {
                     rosterSummoners.add(mapping.get(summonerID));
                 }
                 teamsBySummoner.put(teamrosterSummoners);
             }
             rosters.put(IDteamsBySummoner);
         }
 
         final Map<LongList<Team>> allTeams = new HashMap<LongList<Team>>();
         for(final Long ID : IDs) {
             allTeams.put(IDgetAllTeamsFromJSON(rosters.get(ID)));
         }
         return Collections.unmodifiableMap(allTeams);
     }
 
     private List<TeamMemberInformationgetAllTeamMemberInfoFromJSON(final JSONArray teamMemberList) {
         if(teamMemberList == null) {
             return null;
         }
 
         final List<LongsummonerIDs = getList(teamMemberListm -> (Long)((JSONObject)m).get("playerId"));
         final List<Summonersummoners = .getSummonersByID(summonerIDs);
         final Map<LongSummonermapping = new HashMap<LongSummoner>();
         for(final Summoner summoner : summoners) {
             mapping.put(summoner.IDsummoner);
         }
 
         return getList(teamMemberListm -> {
             final JSONObject member = (JSONObject)m;
             return getTeamMemberInfoFromJSON(mapping.get(member.get("playerId")), member);
         });
     }
 
     private List<TeamMemberInformationgetAllTeamMemberInfoFromJSON(final List<Summonersummonersfinal JSONArray teamMemberList) {
         if(teamMemberList == null) {
             return null;
         }
 
         final Map<LongSummonermapping = new HashMap<LongSummoner>();
         for(final Summoner summoner : summoners) {
             mapping.put(summoner.IDsummoner);
         }
 
         return getList(teamMemberListm -> {
             final JSONObject member = (JSONObject)m;
             return getTeamMemberInfoFromJSON(mapping.get(member.get("playerId")), member);
         });
     }
 
     protected List<TeamgetAllTeamsFromJSON(final JSONObject teamListfinal List<StringteamIDs) {
         final List<LongsummonerIDs = new ArrayList<Long>();
         final Map<JSONObjectList<Long>> rosterIDs = new HashMap<JSONObjectList<Long>>();
         for(final String teamID : teamIDs) {
             final JSONObject team = (JSONObject)teamList.get(teamID);
             final JSONObject roster = (JSONObject)team.get("roster");
             final JSONArray memberList = (JSONArray)roster.get("memberList");
             if(memberList == null) {
                 // Would've already been cached in a non-empty memberList
                 summonerIDs.add((Long)roster.get("ownerId"));
                 rosterIDs.put(teamnew ArrayList<Long>());
                 continue;
             }
 
             final List<LongIDs = new ArrayList<Long>();
             for(final Object memberObj : memberList) {
                 final JSONObject member = (JSONObject)memberObj;
                 final Long memberID = (Long)member.get("playerId");
                 summonerIDs.add(memberID);
                 IDs.add(memberID);
             }
             rosterIDs.put(teamIDs);
         }
 
         final List<Summonersummoners = .getSummonersByID(summonerIDs);
 
         final Map<LongSummonermapping = new HashMap<LongSummoner>();
         for(final Summoner summoner : summoners) {
             mapping.put(summoner.IDsummoner);
         }
 
         final Map<JSONObjectList<Summoner>> rosters = new HashMap<JSONObjectList<Summoner>>();
         for(final JSONObject team : rosterIDs.keySet()) {
             final List<LongrosterByID = rosterIDs.get(team);
             final List<SummonerrosterBySummoner = new ArrayList<Summoner>();
             for(final Long summonerID : rosterByID) {
                 rosterBySummoner.add(mapping.get(summonerID));
             }
             rosters.put(teamrosterBySummoner);
         }
 
         return getAllTeamsFromJSON(rosters);
     }
 
     private List<TeamgetAllTeamsFromJSON(final Map<JSONObjectList<Summoner>> rosters) {
         final List<Teamteams = new ArrayList<Team>();
         for(final JSONObject team : rosters.keySet()) {
             teams.add(getTeamFromJSON(rosters.get(team), team));
         }
         return Collections.unmodifiableList(teams);
     }
 
     public BannedChampion getBannedChampionFromJSON(final JSONObject bannedChampionInfo) {
         if(bannedChampionInfo == null) {
             return null;
         }
 
         final Champion champion = .getChampion(getInteger(bannedChampionInfo"championId"));
         final Integer pickTurn = getInteger(bannedChampionInfo"pickTurn");
         final Side team = getSide(bannedChampionInfo"teamId");
 
         return new BannedChampion(championpickTurnteam);
     }
 
     public BasicDataStats getBasicDataStatsFromJSON(final JSONObject basicDataStatsInfo) {
         if(basicDataStatsInfo == null) {
             return null;
         }
 
         final Double flatArmorMod = (Double)basicDataStatsInfo.get("FlatArmorMod");
         final Double flatArmorPenetrationMod = (Double)basicDataStatsInfo.get("FlatArmorPenetrationMod");
         final Double flatAttackSpeedMod = (Double)basicDataStatsInfo.get("FlatAttackSpeedMod");
         final Double flatBlockMod = (Double)basicDataStatsInfo.get("FlatBlockMod");
         final Double flatCritChanceMod = (Double)basicDataStatsInfo.get("FlatCritChanceMod");
         final Double flatCritDamageMod = (Double)basicDataStatsInfo.get("FlatCritDamageMod");
         final Double flatEXPBonus = (Double)basicDataStatsInfo.get("FlatEXPBonus");
         final Double flatEnergyPoolMod = (Double)basicDataStatsInfo.get("FlatEnergyPoolMod");
         final Double flatEnergyRegenMod = (Double)basicDataStatsInfo.get("FlatEnergyRegenMod");
         final Double flatGoldPer10Mod = (Double)basicDataStatsInfo.get("FlatGoldPer10Mod");
         final Double flatHPPoolMod = (Double)basicDataStatsInfo.get("FlatHPPoolMod");
         final Double flatHPRegenMod = (Double)basicDataStatsInfo.get("FlatHPRegenMod");
         final Double flatMPPoolMod = (Double)basicDataStatsInfo.get("FlatMPPoolMod");
         final Double flatMPRegenMod = (Double)basicDataStatsInfo.get("FlatMPRegenMod");
         final Double flatMagicDamageMod = (Double)basicDataStatsInfo.get("FlatMagicDamageMod");
         final Double flatMagicPenetrationMod = (Double)basicDataStatsInfo.get("FlatMagicPenetrationMod");
         final Double flatMovementSpeedMod = (Double)basicDataStatsInfo.get("FlatMovementSpeedMod");
         final Double flatPhysicalDamageMod = (Double)basicDataStatsInfo.get("FlatPhysicalDamageMod");
         final Double flatSpellBlockMod = (Double)basicDataStatsInfo.get("FlatSpellBlockMod");
         final Double percentArmorMod = (Double)basicDataStatsInfo.get("PercentArmorMod");
         final Double percentArmorPenetrationMod = (Double)basicDataStatsInfo.get("PercentArmorPenetrationMod");
         final Double percentAttackSpeedMod = (Double)basicDataStatsInfo.get("PercentAttackSpeedMod");
         final Double percentBlockMod = (Double)basicDataStatsInfo.get("PercentBlockMod");
         final Double percentCooldownMod = (Double)basicDataStatsInfo.get("PercentCooldownMod");
         final Double percentCritChanceMod = (Double)basicDataStatsInfo.get("PercentCritChanceMod");
         final Double percentCritDamageMod = (Double)basicDataStatsInfo.get("PercentCritDamageMod");
         final Double percentDodgeMod = (Double)basicDataStatsInfo.get("PercentDodgeMod");
         final Double percentEXPBonus = (Double)basicDataStatsInfo.get("PercentEXPBonus");
         final Double percentHPPoolMod = (Double)basicDataStatsInfo.get("PercentHPPoolMod");
         final Double percentHPRegenMod = (Double)basicDataStatsInfo.get("PercentHPRegenMod");
         final Double percentLifeStealMod = (Double)basicDataStatsInfo.get("PercentLifeStealMod");
         final Double percentMPPoolMod = (Double)basicDataStatsInfo.get("PercentMPPoolMod");
         final Double percentMPRegenMod = (Double)basicDataStatsInfo.get("PercentMPRegenMod");
         final Double percentMagicDamageMod = (Double)basicDataStatsInfo.get("PercentMagicDamageMod");
         final Double percentMagicPenetrationMod = (Double)basicDataStatsInfo.get("PercentMagicPenetrationMod");
         final Double percentMovementSpeedMod = (Double)basicDataStatsInfo.get("PercentMovementSpeedMod");
         final Double percentPhysicalDamageMod = (Double)basicDataStatsInfo.get("PercentPhysicalDamageMod");
         final Double percentSpellBlockMod = (Double)basicDataStatsInfo.get("PercentSpellBlockMod");
         final Double percentSpellVampMod = (Double)basicDataStatsInfo.get("PercentSpellVampMod");
         final Double rFlatArmorModPerLevel = (Double)basicDataStatsInfo.get("rFlatArmorModPerLevel");
         final Double rFlatArmorPenetrationMod = (Double)basicDataStatsInfo.get("rFlatArmorPenetrationMod");
         final Double rFlatArmorPenetrationModPerLevel = (Double)basicDataStatsInfo.get("rFlatArmorPenetrationModPerLevel");
         final Double rFlatCritChanceModPerLevel = (Double)basicDataStatsInfo.get("rFlatCritChanceModPerLevel");
         final Double rFlatCritDamageModPerLevel = (Double)basicDataStatsInfo.get("rFlatCritDamageModPerLevel");
         final Double rFlatDodgeMod = (Double)basicDataStatsInfo.get("rFlatDodgeMod");
         final Double rFlatDodgeModPerLevel = (Double)basicDataStatsInfo.get("rFlatDodgeModPerLevel");
         final Double rFlatEnergyModPerLevel = (Double)basicDataStatsInfo.get("rFlatEnergyModPerLevel");
         final Double rFlatEnergyRegenModPerLevel = (Double)basicDataStatsInfo.get("rFlatEnergyRegenModPerLevel");
         final Double rFlatGoldPer10Mod = (Double)basicDataStatsInfo.get("rFlatGoldPer10Mod");
         final Double rFlatHPModPerLevel = (Double)basicDataStatsInfo.get("rFlatHPModPerLevel");
         final Double rFlatHPRegenModPerLevel = (Double)basicDataStatsInfo.get("rFlatHPRegenModPerLevel");
         final Double rFlatMPModPerLevel = (Double)basicDataStatsInfo.get("rFlatMPModPerLevel");
         final Double rFlatMPRegenModPerLevel = (Double)basicDataStatsInfo.get("rFlatMPRegenModPerLevel");
         final Double rFlatMagicDamageModPerLevel = (Double)basicDataStatsInfo.get("rFlatMagicDamageModPerLevel");
         final Double rFlatMagicPenetrationMod = (Double)basicDataStatsInfo.get("rFlatMagicPenetrationMod");
         final Double rFlatMagicPenetrationModPerLevel = (Double)basicDataStatsInfo.get("rFlatMagicPenetrationModPerLevel");
         final Double rFlatMovementSpeedModPerLevel = (Double)basicDataStatsInfo.get("rFlatMovementSpeedModPerLevel");
         final Double rFlatPhysicalDamageModPerLevel = (Double)basicDataStatsInfo.get("rFlatPhysicalDamageModPerLevel");
         final Double rFlatSpellBlockModPerLevel = (Double)basicDataStatsInfo.get("rFlatSpellBlockModPerLevel");
         final Double rFlatTimeDeadMod = (Double)basicDataStatsInfo.get("rFlatTimeDeadMod");
         final Double rFlatTimeDeadModPerLevel = (Double)basicDataStatsInfo.get("rFlatTimeDeadModPerLevel");
         final Double rPercentArmorPenetrationMod = (Double)basicDataStatsInfo.get("rPercentArmorPenetrationMod");
         final Double rPercentArmorPenetrationModPerLevel = (Double)basicDataStatsInfo.get("rPercentArmorPenetrationModPerLevel");
         final Double rPercentAttackSpeedModPerLevel = (Double)basicDataStatsInfo.get("rPercentAttackSpeedModPerLevel");
         final Double rPercentCooldownMod = (Double)basicDataStatsInfo.get("rPercentCooldownMod");
         final Double rPercentCooldownModPerLevel = (Double)basicDataStatsInfo.get("rPercentCooldownModPerLevel");
         final Double rPercentMagicPenetrationMod = (Double)basicDataStatsInfo.get("rPercentMagicPenetrationMod");
         final Double rPercentMagicPenetrationModPerLevel = (Double)basicDataStatsInfo.get("rPercentMagicPenetrationModPerLevel");
         final Double rPercentMovementSpeedModPerLevel = (Double)basicDataStatsInfo.get("rPercentMovementSpeedModPerLevel");
         final Double rPercentTimeDeadMod = (Double)basicDataStatsInfo.get("rPercentTimeDeadMod");
         final Double rPercentTimeDeadModPerLevel = (Double)basicDataStatsInfo.get("rPercentTimeDeadModPerLevel");
 
         return new BasicDataStats(flatArmorModflatArmorPenetrationModflatAttackSpeedModflatBlockModflatCritChanceModflatCritDamageModflatEXPBonus,
                 flatEnergyPoolModflatEnergyRegenModflatGoldPer10ModflatHPPoolModflatHPRegenModflatMPPoolModflatMPRegenModflatMagicDamageMod,
                 flatMagicPenetrationModflatMovementSpeedModflatPhysicalDamageModflatSpellBlockModpercentArmorModpercentArmorPenetrationMod,
                 percentAttackSpeedModpercentBlockModpercentCooldownModpercentCritChanceModpercentCritDamageModpercentDodgeModpercentEXPBonus,
                 percentHPPoolModpercentHPRegenModpercentLifeStealModpercentMPPoolModpercentMPRegenModpercentMagicDamageMod,
                 percentMagicPenetrationModpercentMovementSpeedModpercentPhysicalDamageModpercentSpellBlockModpercentSpellVampMod,
                 rFlatArmorModPerLevelrFlatArmorPenetrationModrFlatArmorPenetrationModPerLevelrFlatCritChanceModPerLevelrFlatCritDamageModPerLevel,
                 rFlatDodgeModrFlatDodgeModPerLevelrFlatEnergyModPerLevelrFlatEnergyRegenModPerLevelrFlatGoldPer10ModrFlatHPModPerLevel,
                 rFlatHPRegenModPerLevelrFlatMPModPerLevelrFlatMPRegenModPerLevelrFlatMagicDamageModPerLevelrFlatMagicPenetrationMod,
                 rFlatMagicPenetrationModPerLevelrFlatMovementSpeedModPerLevelrFlatPhysicalDamageModPerLevelrFlatSpellBlockModPerLevelrFlatTimeDeadMod,
                 rFlatTimeDeadModPerLevelrPercentArmorPenetrationModrPercentArmorPenetrationModPerLevelrPercentAttackSpeedModPerLevel,
                 rPercentCooldownModrPercentCooldownModPerLevelrPercentMagicPenetrationModrPercentMagicPenetrationModPerLevel,
                 rPercentMovementSpeedModPerLevelrPercentTimeDeadModrPercentTimeDeadModPerLevel);
     }
 
     public Block getBlockFromJSON(final JSONObject blockInfo) {
         if(blockInfo == null) {
             return null;
         }
 
         final Boolean recMath = (Boolean)blockInfo.get("recMath");
         final String type = (String)blockInfo.get("type");
         final List<BlockItemitems = getList(blockInfo"items"b -> getBlockItemFromJSON((JSONObject)b));
 
         return new Block(itemsrecMathtype);
     }
 
     public BlockItem getBlockItemFromJSON(final JSONObject blockItemInfo) {
         if(blockItemInfo == null) {
             return null;
         }
 
         final Integer count = getInteger(blockItemInfo"count");
         final Integer ID = getInteger(blockItemInfo"id");
 
         /*
          * Riot's recommended items include some IDs that no longer exist in the
          * database. For now, this will be the fix.
          */
         // TODO: Remove this after rito fixes it.
         Item item = null;
         if(ID != 3186 && ID != 3176 && ID != 3210) {
             item = .getItem(ID);
         }
 
         return new BlockItem(countitem);
     }
 
     public Champion getChampionFromJSON(final JSONObject championInfo) {
         if(championInfo == null) {
             return null;
         }
 
         final List<StringallyTips = getStringList(championInfo"allytips");
         final List<StringenemyTips = getStringList(championInfo"enemytips");
         final List<Stringtags = getStringList(championInfo"tags");
         final String blurb = (String)championInfo.get("blurb");
         final String key = (String)championInfo.get("key");
         final String lore = (String)championInfo.get("lore");
         final String name = (String)championInfo.get("name");
         final String partype = (String)championInfo.get("partype");
         final String title = (String)championInfo.get("title");
         final Integer ID = getInteger(championInfo"id");
         final Image image = getImageFromJSON((JSONObject)championInfo.get("image"));
         final Information info = getInformationFromJSON((JSONObject)championInfo.get("info"));
         final Passive passive = getPassiveFromJSON((JSONObject)championInfo.get("passive"));
         final Stats stats = getStatsFromJSON((JSONObject)championInfo.get("stats"));
         final List<Recommendedrecommended = getList(championInfo"recommended"r -> getRecommendedFromJSON((JSONObject)r));
         final List<Skinskins = getList(championInfo"skins"s -> getSkinFromJSON((JSONObject)s));
         final List<ChampionSpellspells = getList(championInfo"spells"s -> getChampionSpellFromJSON((JSONObject)s));
 
         return new Champion(allyTipsenemyTipstagsblurbkeylorenamepartypetitleIDimageinfopassiverecommendedskinsspellsstats);
     }
 
     public ChampionSpell getChampionSpellFromJSON(final JSONObject championSpellInfo) {
         if(championSpellInfo == null) {
             return null;
         }
 
         final List<Doublecooldown = getDoubleList(championSpellInfo"cooldown");
         final List<Integercost = getIntegerList(championSpellInfo"cost");
         final List<StringeffectBurn = getStringList(championSpellInfo"effectBurn");
         final Integer maxRank = getInteger(championSpellInfo"maxrank");
         final String cooldownBurn = (String)championSpellInfo.get("cooldownBurn");
         final String costBurn = (String)championSpellInfo.get("costBurn");
         final String costType = (String)championSpellInfo.get("costType");
         final String description = (String)championSpellInfo.get("description");
         final String key = (String)championSpellInfo.get("key");
         final String name = (String)championSpellInfo.get("name");
         final String rangeBurn = (String)championSpellInfo.get("rangeBurn");
         final String resource = (String)championSpellInfo.get("resource");
         final String sanitizedDescription = (String)championSpellInfo.get("sanitizedDescription");
         final String sanitizedTooltip = (String)championSpellInfo.get("sanitizedTooltip");
         final String tooltip = (String)championSpellInfo.get("tooltip");
         final Image image = getImageFromJSON((JSONObject)championSpellInfo.get("image"));
         final LevelTip levelTip = getLevelTipFromJSON((JSONObject)championSpellInfo.get("leveltip"));
         final List<ImagealtImages = getList(championSpellInfo"altimages"i -> getImageFromJSON((JSONObject)i));
         final List<SpellVariablesvars = getList(championSpellInfo"vars"v -> getSpellVariablesFromJSON((JSONObject)v));
         final List<List<Double>> effect = getList(championSpellInfo"effect"l -> getDoubleList((JSONArray)l));
 
         List<Integerrange;
         final Object val = championSpellInfo.get("range");
         if(val instanceof String) {
             range = null;
         }
         else {
             range = getIntegerList((JSONArray)val);
         }
 
         return new ChampionSpell(altImagescooldowncooldownBurncostBurncostTypedescriptionkeynamerangeBurnresourcesanitizedDescription,
                 sanitizedTooltiptooltipcostrangeeffecteffectBurnimagelevelTipmaxRankvars);
     }
 
     public ChampionStats getChampionStatsFromJSON(final JSONObject championStatsInfo) {
         if(championStatsInfo == null) {
             return null;
         }
 
         final AggregatedStats stats = getAggregatedStatsFromJSON((JSONObject)championStatsInfo.get("stats"));
         Champion champion;
         final Integer championID = getInteger(championStatsInfo"id");
         if(championID == null || championID == 0) {
             champion = null;
         }
         else {
             champion = .getChampion(championID);
         }
 
         return new ChampionStats(championstats);
     }
 
     public ChampionStatus getChampionStatusFromJSON(final JSONObject championStatusInfo) {
         if(championStatusInfo == null) {
             return null;
         }
 
         final Boolean active = (Boolean)championStatusInfo.get("active");
         final Boolean botEnabled = (Boolean)championStatusInfo.get("botEnabled");
         final Boolean botMmEnabled = (Boolean)championStatusInfo.get("botMmEnabled");
         final Boolean freeToPlay = (Boolean)championStatusInfo.get("freeToPlay");
         final Boolean rankedPlayEnabled = (Boolean)championStatusInfo.get("rankedPlayEnabled");
         final Champion champion = .getChampion(getInteger(championStatusInfo"id"));
 
         return new ChampionStatus(activebotEnabledbotMmEnabledfreeToPlayrankedPlayEnabledchampion);
     }
 
     public Event getEventFromJSON(final JSONObject eventInfofinal Map<IntegerParticipantparticipantsfinal Map<SideMatchTeamteams) {
         if(eventInfo == null) {
             return null;
         }
 
         String typeName = (String)eventInfo.get("buildingType");
         final BuildingType buildingType = typeName == null ? null : BuildingType.valueOf(typeName);
         typeName = (String)eventInfo.get("eventType");
         final EventType eventType = typeName == null ? null : EventType.valueOf(typeName);
         typeName = (String)eventInfo.get("laneType");
         final LaneType laneType = typeName == null ? null : LaneType.valueOf(typeName);
         typeName = (String)eventInfo.get("levelUpType");
         final LevelUpType levelUpType = typeName == null ? null : LevelUpType.valueOf(typeName);
         typeName = (String)eventInfo.get("monsterType");
         final MonsterType monsterType = typeName == null ? null : MonsterType.valueOf(typeName);
         typeName = (String)eventInfo.get("towerType");
         final TowerType towerType = typeName == null ? null : TowerType.valueOf(typeName);
         typeName = (String)eventInfo.get("wardType");
         final WardType wardType = typeName == null ? null : WardType.valueOf(typeName);
 
         Integer id = getInteger(eventInfo"itemAfter");
         final Item itemAfter = id == null ? null : .getItem(id);
         id = getInteger(eventInfo"itemBefore");
         final Item itemBefore = id == null ? null : .getItem(id);
         id = getInteger(eventInfo"itemBefore");
         final Item item = id == null ? null : .getItem(id);
 
         final Integer skillSlot = getInteger(eventInfo"skillSlot");
         final Side side = getSide(eventInfo"teamId");
         final Position position = getPositionFromJSON((JSONObject)eventInfo.get("position"));
         final Duration timestamp = getDuration(eventInfo"timestamp".);
         final Participant creator = participants.get(getInteger(eventInfo"creatorId"));
         final Participant killer = participants.get(getInteger(eventInfo"killerId"));
         final Participant victim = participants.