Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   package com.robrua.orianna.api;
   
   import java.util.ArrayList;
   import java.util.Arrays;
   import java.util.Collections;
   import java.util.HashMap;
   import java.util.HashSet;
   import java.util.List;
   import java.util.Map;
  import java.util.Set;
  
  
Accesses the LoL REST API and provides results in easy-to-use Java objects.
  • Replaces foreign key ID values with the referenced object
  • Makes most efficient use of API calls to minimize load
  • Caches static data and summoner information to accelerate access
  • Automatically throttles requests to fit rate limits
  • Ensures well-formed API requests

Author(s):
Rob Rua (FatalElement - NA) (robrua@alumni.cmu.edu)
  
  public class RiotAPI {
      private class Cache {
          public final Map<IntegerChampionchampions = new ConcurrentHashMap<IntegerChampion>();
          public boolean championsFilled = false;
          public final Map<IntegerItemitems = new ConcurrentHashMap<IntegerItem>();
          public boolean itemsFilled = false;
          public final Map<IntegerMasterymasteries = new ConcurrentHashMap<IntegerMastery>();
          public boolean masteriesFilled = false;
          public MasteryTree masteryTree = null;
          public final Map<IntegerRunerunes = new ConcurrentHashMap<IntegerRune>();
          public boolean runesFilled = false;
          public final Map<LongSummonersummonerIDs = new ConcurrentHashMap<LongSummoner>();
          public final Map<StringSummonersummonerNames = new ConcurrentHashMap<StringSummoner>();
          public final Map<IntegerSummonerSpellsummonerSpells = new ConcurrentHashMap<IntegerSummonerSpell>();
          public boolean summonerSpellsFilled = false;
      }
  
      private final static int LEAGUE_TEAM_ID_LIMIT = 10;
      private final static JSONParser parser = new JSONParser();
      private final static int STANDARD_ID_LIMIT = 40;
  
      private static List<LonggetIDsFromSummoners(final List<Summonersummoners) {
          return summoners.stream().map((summoner) -> summoner.ID).collect(Collectors.toList());
      }
  
      private static List<StringgetIDsFromTeams(final List<Teamteams) {
          return teams.stream().map((team) -> team.ID).collect(Collectors.toList());
      }
  
      @SuppressWarnings("unchecked")
      private static <T> JSONObject handleIDCountLimit(final List<T> IDsfinal Function<List<T>, StringAPICallfinal int limitPerCall) {
          if(IDs.size() > limitPerCall) {
              final JSONObject allIDs = new JSONObject();
              final List<List<T>> splitIDs = splitIDList(IDslimitPerCall);
              for(final List<T> IDBatch : splitIDs) {
                  final String json = APICall.apply(IDBatch);
                  try {
                      final JSONObject moreIDs = (JSONObject).parse(json);
                     allIDs.putAll(moreIDs);
                 }
                 catch(final ParseException e) {
                     throw handleParseException(e);
                 }
             }
 
             return allIDs;
         }
         else {
             final String json = APICall.apply(IDs);
 
             try {
                 return (JSONObject).parse(json);
             }
             catch(final ParseException e) {
                 throw handleParseException(e);
             }
         }
     }
 
     private static APIException handleParseException(final ParseException e) {
         return new APIException(..e);
     }
 
     private static <T> List<List<T>> splitIDList(final List<T> IDsfinal int maxSize) {
         final int numRequests = (IDs.size() - 1) / maxSize + 1;
         final List<List<T>> splitIDs = new ArrayList<List<T>>(numRequests);
         for(int i = 0; i < numRequestsi++) {
             final List<T> IDBatch = new ArrayList<T>();
 
             final int start = i * maxSize;
             for(int j = startj < start + maxSize && j < IDs.size(); j++) {
                 IDBatch.add(IDs.get(j));
             }
 
             splitIDs.add(Collections.unmodifiableList(IDBatch));
         }
 
         return Collections.unmodifiableList(splitIDs);
     }
 
     private static <T> Map<Summoner, T> summonerMapFromID(final List<Summonersummonersfinal Map<Long, T> IDMap) {
         final Map<Summoner, T> map = new HashMap<Summoner, T>();
         summoners.forEach((summoner) -> map.put(summonerIDMap.get(summoner.ID)));
         return Collections.unmodifiableMap(map);
     }
 
     private static <T> Map<Team, T> teamMapFromID(final List<Teamteamsfinal Map<String, T> IDMap) {
         final Map<Team, T> map = new HashMap<Team, T>();
         teams.forEach((team) -> map.put(teamIDMap.get(team.ID)));
         return Collections.unmodifiableMap(map);
     }
 
     private final JSONRiotAPI API;
     private Cache cache;
     private final JSONConverter converter;

    

Parameters:
mirror the data server to query
forRegion the region for which to query data
APIKey your LoL API key
 
     public RiotAPI(final Region mirrorfinal Region forRegionfinal String APIKey) {
         this(mirrorforRegionAPIKeynull);
     }

    

Parameters:
mirror the data server to query
forRegion the region for which to query data
APIKey your LoL API key
rateLimiter queries will be throttled automatically to meet this rate limit
 
     public RiotAPI(final Region mirrorfinal Region forRegionfinal String APIKeyfinal RateLimiter rateLimiter) {
          = new JSONRiotAPI(mirrorforRegionAPIKeyrateLimiter);
          = new JSONConverter(this);
          = new Cache();
     }

    

Parameters:
forRegion the region for which to query data
APIKey your LoL API key
 
     public RiotAPI(final Region forRegionfinal String APIKey) {
         this(forRegionforRegionAPIKeynull);
     }

    

Parameters:
forRegion the region for which to query data
APIKey your LoL API key
rateLimiter queries will be throttled automatically to meet this rate limit
 
     public RiotAPI(final Region forRegionfinal String APIKeyfinal RateLimiter rateLimiter) {
         this(forRegionforRegionAPIKeyrateLimiter);
     }

    
Caches all Items, Champions, Runes, Masteries, and Summoner Spells in bulk.
 
     public void cacheAllStaticData() {
         getItems();
         getChampions();
         getMasteries();
         getRunes();
         getSummonerSpells();
     }

    
Clears all cached information
 
     public void clearCache() {
          = new Cache();
     }

    

Parameters:
summoner the summoner to get information for
Returns:
the summoner's active mastery page
See also:
LoL API Specification
 
     public MasteryPage getActiveMasteryPage(final Summoner summoner) {
         return getActiveMasteryPageByID(summoner.ID);
     }

    

Parameters:
summonerID the summoner to get information for
Returns:
the summoner's active mastery page
See also:
LoL API Specification
 
     public MasteryPage getActiveMasteryPageByID(final long summonerID) {
         return getMasteryPagesByID(summonerID).stream().filter((page) -> page.current).findAny().get();
     }

    

Parameters:
summonerName the summoner to get information for
Returns:
the summoner's active mastery page
See also:
LoL API Specification
 
     public MasteryPage getActiveMasteryPageByName(final String summonerName) {
         return getActiveMasteryPage(getSummoner(summonerName));
     }

    

Parameters:
summoners the summoners to get information for
Returns:
the summoners' active mastery pages
See also:
LoL API Specification
 
     public Map<SummonerMasteryPagegetActiveMasteryPages(final List<Summonersummoners) {
         final Map<LongMasteryPageallPages = getActiveMasteryPagesByIDs(getIDsFromSummoners(summoners));
         return summonerMapFromID(summonersallPages);
     }

    

Parameters:
summoners the summoners to get information for
Returns:
the summoners' active mastery pages
See also:
LoL API Specification
 
     public Map<SummonerMasteryPagegetActiveMasteryPages(final Summoner... summoners) {
         return getActiveMasteryPages(Arrays.asList(summoners));
     }

    

Parameters:
summonerIDs the summoners to get information for
Returns:
the summoners' active mastery pages
See also:
LoL API Specification
 
     public Map<LongMasteryPagegetActiveMasteryPagesByIDs(final List<LongsummonerIDs) {
         final Map<LongList<MasteryPage>> pages = getMasteryPagesByIDs(summonerIDs);
         return pages.entrySet().stream()
                 .collect(Collectors.toMap((entry) -> entry.getKey(), (entry) -> entry.getValue().stream().filter((page) -> page.current).findAny().get()));
     }

    

Parameters:
summonerIDs the summoners to get information for
Returns:
the summoners' active mastery pages
See also:
LoL API Specification
 
     public Map<LongMasteryPagegetActiveMasteryPagesByIDs(final Long... summonerIDs) {
         return getActiveMasteryPagesByIDs(Arrays.asList(summonerIDs));
     }

    

Parameters:
summonerNames the summoners to get information for
Returns:
the summoners' active mastery pages
See also:
LoL API Specification
 
     public Map<SummonerMasteryPagegetActiveMasteryPagesByNames(final List<StringsummonerNames) {
         final List<Summonersummoners = getSummoners(summonerNames);
         return getActiveMasteryPages(summoners);
     }

    

Parameters:
summonerNames the summoners to get information for
Returns:
the summoners' active mastery pages
See also:
LoL API Specification
 
     public Map<SummonerMasteryPagegetActiveMasteryPagesByNames(final String... summonerNames) {
         return getActiveMasteryPagesByNames(Arrays.asList(summonerNames));
     }

    

Parameters:
summoner the summoner to get information for
Returns:
the summoner's active rune page
See also:
LoL API Specification
 
     public RunePage getActiveRunePage(final Summoner summoner) {
         return getActiveRunePageByID(summoner.ID);
     }

    

Parameters:
summonerID the summoner to get information for
Returns:
the summoner's active rune page
See also:
LoL API Specification
 
     public RunePage getActiveRunePageByID(final long summonerID) {
         return getRunePagesByID(summonerID).stream().filter((page) -> page.current).findAny().get();
     }

    

Parameters:
summonerName the summoner to get information for
Returns:
the summoner's active rune page
See also:
LoL API Specification
 
     public RunePage getActiveRunePageByName(final String summonerName) {
         return getActiveRunePage(getSummoner(summonerName));
     }

    

Parameters:
summoners the summoners to get information for
Returns:
the summoners' active rune pages
See also:
LoL API Specification
 
     public Map<SummonerRunePagegetActiveRunePages(final List<Summonersummoners) {
         final Map<LongRunePageallPages = getActiveRunePagesByIDs(getIDsFromSummoners(summoners));
         return summonerMapFromID(summonersallPages);
     }

    

Parameters:
summoners the summoners to get information for
Returns:
the summoners' active rune pages
See also:
LoL API Specification
 
     public Map<SummonerRunePagegetActiveRunePages(final Summoner... summoners) {
         return getActiveRunePages(Arrays.asList(summoners));
     }

    

Parameters:
summonerIDs the summoners to get information for
Returns:
the summoners' active rune pages
See also:
LoL API Specification
 
     public Map<LongRunePagegetActiveRunePagesByIDs(final List<LongsummonerIDs) {
         final Map<LongList<RunePage>> pages = getRunePagesByIDs(summonerIDs);
         return pages.entrySet().stream()
                 .collect(Collectors.toMap((entry) -> entry.getKey(), (entry) -> entry.getValue().stream().filter((page) -> page.current).findAny().get()));
     }

    

Parameters:
summonerIDs the summoners to get information for
Returns:
the summoners' active rune pages
See also:
LoL API Specification
 
     public Map<LongRunePagegetActiveRunePagesByIDs(final Long... summonerIDs) {
         return getActiveRunePagesByIDs(Arrays.asList(summonerIDs));
     }

    

Parameters:
summonerNames the summoners to get information for
Returns:
the summoners' active rune pages
See also:
LoL API Specification
 
     public Map<SummonerRunePagegetActiveRunePagesByNames(final List<StringsummonerNames) {
         final List<Summonersummoners = getSummoners(summonerNames);
         return getActiveRunePages(summoners);
     }

    

Parameters:
summonerNames the summoners to get information for
Returns:
the summoners' active rune pages
See also:
LoL API Specification
 
     public Map<SummonerRunePagegetActiveRunePagesByNames(final String... summonerNames) {
         return getActiveRunePagesByNames(Arrays.asList(summonerNames));
     }

    

Returns:
the solo-queue challenger league
See also:
LoL API Specification
 
     public League getChallengerLeague() {
     }

    

Parameters:
type the queue for which to get the Challenger league
Returns:
the challenger league
See also:
LoL API Specification
 
     public League getChallengerLeague(final LeagueType type) {
         final String json = .getChallengerLeague(type);
         try {
             return .getLeagueFromJSON((JSONObject).parse(json));
         }
         catch(final ParseException e) {
             throw handleParseException(e);
         }
     }

    

Parameters:
championID the champion to get information for
Returns:
the champion
See also:
LoL API Specification
 
     public Champion getChampion(final int championID) {
         Champion champion = ..get(championID);
 
         if(champion == null) {
             if(!.) {
                 getItems(); // Cache in bulk to minimize API calls
             }
 
             final Set<ChampionDatachampionData = new HashSet<ChampionData>();
             championData.add(.);
             final String json = .getChampion(championIDchampionData);
 
             try {
                 champion = .getChampionFromJSON((JSONObject).parse(json));
             }
             catch(final ParseException e) {
                 throw handleParseException(e);
             }
             ..put(championIDchampion);
         }
 
         return champion;
     }

    
Not supported by the API, done locally (and slowly at that)

Parameters:
championName the champion's name
Returns:
the champion
 
     public Champion getChampion(final String championName) {
         final List<Championchampions = getChampions();
         return champions.stream().filter((champion) -> champion.name.equals(championName)).findAny().get();
     }

    

Returns:
all champions
See also:
LoL API Specification
 
     public List<ChampiongetChampions() {
         if(.) {
             final List<Championchampions = new ArrayList<Champion>();
             champions.addAll(..values());
             return Collections.unmodifiableList(champions);
         }
 
         if(!.) {
             getItems(); // Cache in bulk to minimize API calls
         }
 
         final Set<ChampionDatachampionData = new HashSet<ChampionData>();
         championData.add(.);
 
         final String json = .getChampions(championData);
         JSONObject championList;
         try {
             championList = (JSONObject).parse(json);
         }
         catch(final ParseException e) {
             throw handleParseException(e);
         }
 
         final List<Championchampions = JSONConverter.getListFromMap(championList"data"c -> .getChampionFromJSON((JSONObject)c));
         for(final Champion champion : champions) {
             ..put(champion.IDchampion);
         }
         . = true;
 
         return champions;
     }

    
Not supported by the API, done locally (and slowly at that)

Parameters:
championNames the champions' names
Returns:
the champions
 
     public List<ChampiongetChampions(final List<StringchampionNames) {
         final List<Championchampions = getChampions();
         return Collections.unmodifiableList(champions.stream().filter((champion) -> championNames.contains(champion.name)).collect(Collectors.toList()));
     }

    
Not supported by the API, done locally (and slowly at that)

Parameters:
championNames the champions' names
Returns:
the champions
 
     public List<ChampiongetChampions(final String... championNames) {
         return getChampions(Arrays.asList(championNames));
     }

    

Parameters:
champion the champion to get information about
Returns:
the champion's status
See also:
LoL API Specification
 
     public ChampionStatus getChampionStatus(final Champion champion) {
         return getChampionStatus(champion.ID);
     }

    

Parameters:
championID the champion to get information for
Returns:
the champion's status
See also:
LoL API Specification
 
     public ChampionStatus getChampionStatus(final int championID) {
         final String json = .getChampionStatus(championID);
         try {
             return .getChampionStatusFromJSON((JSONObject).parse(json));
         }
         catch(final ParseException e) {
             throw handleParseException(e);
         }
     }

    

Returns:
all champions' statuses
See also:
LoL API Specification
 
     public List<ChampionStatusgetChampionStatuses() {
         return getChampionStatuses(false);
     }

    

Parameters:
onlyFreeToPlay whether to only show statuses for free to play champions
Returns:
champions' statuses
See also:
LoL API Specification
 
     public List<ChampionStatusgetChampionStatuses(final boolean onlyFreeToPlay) {
         if(!.) {
             getChampions(); // Cache in bulk to minimize API calls
         }
 
         final String json = .getChampionStatuses(onlyFreeToPlay);
         try {
             return JSONConverter.getList((JSONObject).parse(json), "champions"s -> .getChampionStatusFromJSON((JSONObject)s));
         }
         catch(final ParseException e) {
             throw handleParseException(e);
         }
     }

    

Parameters:
itemID the item to get information for
Returns:
the item
See also:
LoL API Specification
 
     public Item getItem(final int itemID) {
         Item item = ..get(itemID);
 
         if(item == null) {
             final Set<ItemDataitemData = new HashSet<ItemData>();
             itemData.add(.);
             final String json = .getItem(itemIDitemData);
 
             try {
                 item = .getItemFromJSON((JSONObject).parse(json));
             }
             catch(final ParseException e) {
                 throw handleParseException(e);
             }
             ..put(itemIDitem);
         }
 
         return item;
     }

    

Returns:
all items
See also:
LoL API Specification
 
     public List<ItemgetItems() {
         if(.) {
             final List<Itemitems = new ArrayList<Item>();
             items.addAll(..values());
             return Collections.unmodifiableList(items);
         }
 
         final Set<ItemDataitemData = new HashSet<ItemData>();
         itemData.add(.);
 
         final String json = .getItems(itemData);
         JSONObject itemList;
         try {
             itemList = (JSONObject).parse(json);
         }
         catch(final ParseException e) {
             throw handleParseException(e);
         }
 
         final List<Itemitems = JSONConverter.getListFromMap(itemList"data"i -> .getItemFromJSON((JSONObject)i));
         for(final Item item : items) {
             ..put(item.IDitem);
         }
         . = true;
 
         return items;
     }

    

Parameters:
summoner the summoner to get information for
Returns:
the summoner's leagues
See also:
LoL API Specification
 
     public List<LeaguegetLeagueEntriesBySummoner(final Summoner summoner) {
         return getLeagueEntriesBySummonerID(summoner.ID);
     }

    

Parameters:
summonerID the summoner to get information for
Returns:
the summoner's leagues
See also:
LoL API Specification
 
     public List<LeaguegetLeagueEntriesBySummonerID(final Long summonerID) {
         final String json = .getSummonerLeagueEntriesByID(summonerID);
         try {
             return JSONConverter.getList((JSONObject).parse(json), Long.toString(summonerID), l -> .getLeagueFromJSON((JSONObject)l));
         }
         catch(final ParseException e) {
             throw handleParseException(e);
         }
     }

    

Parameters:
summonerIDs the summoners to get information for
Returns:
the summoners' leagues
See also:
LoL API Specification
 
     public Map<LongList<League>> getLeagueEntriesBySummonerIDs(final List<LongsummonerIDs) {
         final JSONObject summonerList = handleIDCountLimit(summonerIDs, (IDs) -> .getSummonersLeagueEntriesByID(IDs), );
 
         final Map<LongList<League>> allLeagues = new HashMap<LongList<League>>();
         for(final Long summonerID : summonerIDs) {
             final List<Leagueleagues = JSONConverter.getList(summonerList, Long.toString(summonerID), l -> .getLeagueFromJSON((JSONObject)l));
             allLeagues.put(summonerIDleagues);
         }
 
         return Collections.unmodifiableMap(allLeagues);
     }

    

Parameters:
summonerIDs the summoners to get information for
Returns:
the summoners' leagues
See also:
LoL API Specification
 
     public Map<LongList<League>> getLeagueEntriesBySummonerIDs(final Long... summonerIDs) {
         return getLeagueEntriesBySummonerIDs(Arrays.asList(summonerIDs));
     }

    

Parameters:
summonerName the summoner to get information for
Returns:
the summoner's leagues
See also:
LoL API Specification
 
     public List<LeaguegetLeagueEntriesBySummonerName(final String summonerName) {
         return getLeagueEntriesBySummoner(getSummoner(summonerName));
     }

    

Parameters:
summonerNames the summoners to get information for
Returns:
the summoners' leagues
See also:
LoL API Specification
 
     public Map<SummonerList<League>> getLeagueEntriesBySummonerNames(final List<StringsummonerNames) {
         final List<Summonersummoners = getSummoners(summonerNames);
         return getLeagueEntriesBySummoners(summoners);
     }

    

Parameters:
summonerNames the summoners to get information for
Returns:
the summoners' leagues
See also:
LoL API Specification
 
     public Map<SummonerList<League>> getLeagueEntriesBySummonerNames(final String... summonerNames) {
         return getLeagueEntriesBySummonerNames(Arrays.asList(summonerNames));
     }

    

Parameters:
summoners the summoners to get information for
Returns:
the summoners' leagues
See also:
LoL API Specification
 
     public Map<SummonerList<League>> getLeagueEntriesBySummoners(final List<Summonersummoners) {
         final Map<LongList<League>> byID = getLeagueEntriesBySummonerIDs(getIDsFromSummoners(summoners));
         return summonerMapFromID(summonersbyID);
     }

    

Parameters:
summoners the summoners to get information for
Returns:
the summoners' leagues
See also:
LoL API Specification
 
     public Map<SummonerList<League>> getLeagueEntriesBySummoners(final Summoner... summoners) {
         return getLeagueEntriesBySummoners(Arrays.asList(summoners));
     }

    

Parameters:
team the team to get information about
Returns:
the team's leagues
See also:
LoL API Specification
 
     public List<LeaguegetLeagueEntriesByTeam(final Team team) {
         return getLeagueEntriesByTeamID(team.ID);
     }

    

Parameters:
teamID the team to get information for
Returns:
the team's leagues
See also:
LoL API Specification
 
     public List<LeaguegetLeagueEntriesByTeamID(final String teamID) {
         final String json = .getTeamLeagueEntriesByID(teamID);
         try {
             return JSONConverter.getList((JSONObject).parse(json), teamIDl -> .getLeagueFromJSON((JSONObject)l));
         }
         catch(final ParseException e) {
             throw handleParseException(e);
         }
     }

    

Parameters:
teamIDs the teams to get information for
Returns:
the teams' leagues
See also:
LoL API Specification
 
     public Map<StringList<League>> getLeagueEntriesByTeamIDs(final List<StringteamIDs) {
         final JSONObject teamList = handleIDCountLimit(teamIDs, (IDs) -> .getTeamsLeagueEntriesByID(IDs), );
 
         final Map<StringList<League>> allLeagues = new HashMap<StringList<League>>();
         for(final String teamID : teamIDs) {
             final List<Leagueleagues = JSONConverter.getList(teamListteamIDl -> .getLeagueFromJSON((JSONObject)l));
             allLeagues.put(teamIDleagues);
         }
 
         return Collections.unmodifiableMap(allLeagues);
     }

    

Parameters:
teamIDs the teams to get information for
Returns:
the teams' leagues
See also:
LoL API Specification
 
     public Map<StringList<League>> getLeagueEntriesByTeamIDs(final String... teamIDs) {
         return getLeagueEntriesByTeamIDs(Arrays.asList(teamIDs));
     }

    

Parameters:
teams the teams to get information about
Returns:
the teams' leagues
See also:
LoL API Specification
 
     public Map<TeamList<League>> getLeagueEntriesByTeams(final List<Teamteams) {
         final Map<StringList<League>> byID = getLeagueEntriesByTeamIDs(getIDsFromTeams(teams));
         return teamMapFromID(teamsbyID);
     }

    

Parameters:
teams the teams to get information about
Returns:
the teams' leagues
See also:
LoL API Specification
 
     public Map<TeamList<League>> getLeagueEntriesByTeams(final Team... teams) {
         return getLeagueEntriesByTeams(Arrays.asList(teams));
     }

    

Parameters:
summoner the summoner to get information for
Returns:
the summoner's leagues
See also:
LoL API Specification
 
     public List<LeaguegetLeaguesBySummoner(final Summoner summoner) {
         return getLeaguesBySummonerID(summoner.ID);
     }

    

Parameters:
summonerID the summoner to get information for
Returns:
the summoner's leagues
See also:
LoL API Specification
 
     public List<LeaguegetLeaguesBySummonerID(final Long summonerID) {
         final String json = .getSummonerLeaguesByID(summonerID);
         try {
             return JSONConverter.getList((JSONObject).parse(json), Long.toString(summonerID), l -> .getLeagueFromJSON((JSONObject)l));
         }
         catch(final ParseException e) {
             throw handleParseException(e);
         }
     }

    

Parameters:
summonerIDs the summoners to get information for
Returns:
the summoners' leagues
See also:
LoL API Specification
 
     public Map<LongList<League>> getLeaguesBySummonerIDs(final List<LongsummonerIDs) {
         final JSONObject summonerList = handleIDCountLimit(summonerIDs, (IDs) -> .getSummonersLeaguesByID(IDs), );
 
         final Map<LongList<League>> allLeagues = new HashMap<LongList<League>>();
         for(final Long summonerID : summonerIDs) {
             List<Leagueleagues;
             leagues = JSONConverter.getList(summonerList, Long.toString(summonerID), l -> .getLeagueFromJSON((JSONObject)l));
             allLeagues.put(summonerIDleagues);
         }
 
         return Collections.unmodifiableMap(allLeagues);
     }

    

Parameters:
summonerIDs the summoners to get information for
Returns:
the summoners' leagues
See also:
LoL API Specification
 
     public Map<LongList<League>> getLeaguesBySummonerIDs(final Long... summonerIDs) {
         return getLeaguesBySummonerIDs(Arrays.asList(summonerIDs));
     }

    

Parameters:
summonerName the summoner to get information for
Returns:
the summoner's leagues
See also:
LoL API Specification
 
     public List<LeaguegetLeaguesBySummonerName(final String summonerName) {
         return getLeaguesBySummoner(getSummoner(summonerName));
     }

    

Parameters:
summonerNames the summoners to get information for
Returns:
the summoners' leagues
See also:
LoL API Specification
 
     public Map<SummonerList<League>> getLeaguesBySummonerNames(final List<StringsummonerNames) {
         final List<Summonersummoners = getSummoners(summonerNames);
         return getLeaguesBySummoners(summoners);
     }

    

Parameters:
summonerNames the summoners to get information for
Returns:
the summoners' leagues
See also:
LoL API Specification
 
     public Map<SummonerList<League>> getLeaguesBySummonerNames(final String... summonerNames) {
         return getLeaguesBySummonerNames(Arrays.asList(summonerNames));
     }

    

Parameters:
summoners the summoners to get information for
Returns:
the summoners' leagues
See also:
LoL API Specification
 
     public Map<SummonerList<League>> getLeaguesBySummoners(final List<Summonersummoners) {
         final Map<LongList<League>> byID = getLeaguesBySummonerIDs(getIDsFromSummoners(summoners));
         return summonerMapFromID(summonersbyID);
     }

    

Parameters:
summoners the summoners to get information for
Returns:
the summoners' leagues
See also:
LoL API Specification
 
     public Map<SummonerList<League>> getLeaguesBySummoners(final Summoner... summoners) {
         return getLeaguesBySummoners(Arrays.asList(summoners));
     }

    

Parameters:
team the team to get information about
Returns:
the team's leagues
See also:
LoL API Specification
    public List<LeaguegetLeaguesByTeam(final Team team) {
        return getLeaguesByTeamID(team.ID);
    }

    

Parameters:
teamID the team to get information for
Returns:
the team's leagues
See also:
LoL API Specification
    public List<LeaguegetLeaguesByTeamID(final String teamID) {
        final String json = .getTeamLeaguesByID(teamID);
        try {
            return JSONConverter.getList((JSONObject).parse(json), teamIDt -> .getLeagueFromJSON((JSONObject)t));
        }
        catch(final ParseException e) {
            throw handleParseException(e);
        }
    }

    

Parameters:
teamIDs the teams to get information for
Returns:
the teams' leagues
See also:
LoL API Specification
    public Map<StringList<League>> getLeaguesByTeamIDs(final List<StringteamIDs) {
        final JSONObject teamList = handleIDCountLimit(teamIDs, (IDs) -> .getTeamsLeaguesByID(IDs), );
        final Map<StringList<League>> allLeagues = new HashMap<StringList<League>>();
        for(final String teamID : teamIDs) {
            final List<Leagueleagues = JSONConverter.getList(teamListteamIDl -> .getLeagueFromJSON((JSONObject)l));
            allLeagues.put(teamIDleagues);
        }
        return Collections.unmodifiableMap(allLeagues);
    }

    

Parameters:
teamIDs the teams to get information for
Returns:
the teams' leagues
See also:
LoL API Specification
    public Map<StringList<League>> getLeaguesByTeamIDs(final String... teamIDs) {
        return getLeaguesByTeamIDs(Arrays.asList(teamIDs));
    }

    

Parameters:
teams the teams to get information about
Returns:
the teams' leagues
See also:
LoL API Specification
    public Map<TeamList<League>> getLeaguesByTeams(final List<Teamteams) {
        final Map<StringList<League>> byID = getLeaguesByTeamIDs(getIDsFromTeams(teams));
        return teamMapFromID(teamsbyID);
    }

    

Parameters:
teams the teams to get information about
Returns:
the teams' leagues
See also:
LoL API Specification
    public Map<TeamList<League>> getLeaguesByTeams(final Team... teams) {
        return getLeaguesByTeams(Arrays.asList(teams));
    }

    

Returns:
all masteries
See also:
LoL API Specification
    public List<MasterygetMasteries() {
        if(.) {
            final List<Masterymasteries = new ArrayList<Mastery>();
            masteries.addAll(..values());
            return Collections.unmodifiableList(masteries);
        }
        final Set<MasteryDatamasteryData = new HashSet<MasteryData>();
        masteryData.add(.);
        final String json = .getMasteries(masteryData);
        JSONObject masteryList;
        try {
            masteryList = (JSONObject).parse(json);
        }
        catch(final ParseException e) {
            throw handleParseException(e);
        }
        final List<Masterymasteries = JSONConverter.getListFromMap(masteryList"data"m -> .getMasteryFromJSON((JSONObject)m));
        for(final Mastery mastery : masteries) {
            ..put(mastery.IDmastery);
        }
        . = .getMasteryTreeFromJSON((JSONObject)masteryList.get("tree"));
        . = true;
        return masteries;
    }

    

Parameters:
masteryID the mastery to get information for
Returns:
the mastery
See also:
LoL API Specification
    public Mastery getMastery(final int masteryID) {
        Mastery mastery = ..get(masteryID);
        if(mastery == null) {
            final Set<MasteryDatamasteryData = new HashSet<MasteryData>();
            masteryData.add(.);
            final String json = .getMastery(masteryIDmasteryData);
            try {
                mastery = .getMasteryFromJSON((JSONObject).parse(json));
            }
            catch(final ParseException e) {
                throw handleParseException(e);
            }
            ..put(masteryIDmastery);
        }
        return mastery;
    }

    

Parameters:
summoners the summoners to get information for
Returns:
the summoners' mastery pages
See also:
LoL API Specification
    public Map<SummonerList<MasteryPage>> getMasteryPages(final List<Summonersummoners) {
        final Map<LongList<MasteryPage>> allPages = getMasteryPagesByIDs(getIDsFromSummoners(summoners));
        return summonerMapFromID(summonersallPages);
    }

    

Parameters:
summoners the summoners to get information for
Returns:
the summoners' mastery pages
See also:
LoL API Specification
    public Map<SummonerList<MasteryPage>> getMasteryPages(final Summoner... summoners) {
        return getMasteryPages(Arrays.asList(summoners));
    }

    

Parameters:
summoner the summoner to get information for
Returns:
the summoner's mastery pages
See also:
LoL API Specification
    public List<MasteryPagegetMasteryPages(final Summoner summoner) {
        return getMasteryPagesByID(summoner.ID);
    }

    

Parameters:
summonerID the summoner to get information for
Returns:
the summoner's mastery pages
See also:
LoL API Specification
    public List<MasteryPagegetMasteryPagesByID(final long summonerID) {
        if(!.) {
            getMasteries(); // Cache in bulk to minimize API calls
            // Necessary to get mastery tree as well
        }
        final String json = .getSummonerMasteriesByID(summonerID);
        JSONObject summonerList;
        try {
            summonerList = (JSONObject).parse(json);
        }
        catch(final ParseException e) {
            throw handleParseException(e);
        }
        final JSONObject summonerObj = (JSONObject)summonerList.get(Long.toString(summonerID));
        return JSONConverter.getList(summonerObj"pages"p -> .getMasteryPageFromJSON((JSONObject)p.));
    }

    

Parameters:
summonerIDs the summoners to get information for
Returns:
the summoners' mastery pages
See also:
LoL API Specification
    public Map<LongList<MasteryPage>> getMasteryPagesByIDs(final List<LongsummonerIDs) {
        if(!.) {
            getMasteries(); // Cache in bulk to minimize API calls
            // Necessary to get mastery tree as well
        }
        final JSONObject summonerList = handleIDCountLimit(summonerIDs, (IDs) -> .getSummonersMasteriesByID(IDs), );
        final Map<LongList<MasteryPage>> allPages = new HashMap<LongList<MasteryPage>>();
        for(final Long summonerID : summonerIDs) {
            final JSONObject summonerObj = (JSONObject)summonerList.get(Long.toString(summonerID));
            final List<MasteryPagemasteryPages = JSONConverter.getList(summonerObj"pages",
                    p -> .getMasteryPageFromJSON((JSONObject)p.));
            allPages.put(summonerIDmasteryPages);
        }
        return Collections.unmodifiableMap(allPages);
    }

    

Parameters:
summonerIDs the summoners to get information for
Returns:
the summoners' mastery pages
See also:
LoL API Specification
    public Map<LongList<MasteryPage>> getMasteryPagesByIDs(final Long... summonerIDs) {
        return getMasteryPagesByIDs(Arrays.asList(summonerIDs));
    }

    

Parameters:
summonerName the summoner to get information for
Returns:
the summoner's mastery pages
See also:
LoL API Specification
    public List<MasteryPagegetMasteryPagesByName(final String summonerName) {
        return getMasteryPages(getSummoner(summonerName));
    }

    

Parameters:
summonerNames the summoners to get information for
Returns:
the summoners' mastery pages
See also:
LoL API Specification
    public Map<SummonerList<MasteryPage>> getMasteryPagesByNames(final List<StringsummonerNames) {
        final List<Summonersummoners = getSummoners(summonerNames);
        return getMasteryPages(summoners);
    }

    

Parameters:
summonerNames the summoners to get information for
Returns:
the summoners' mastery pages
See also:
LoL API Specification
    public Map<SummonerList<MasteryPage>> getMasteryPagesByNames(final String... summonerNames) {
        return getMasteryPagesByNames(Arrays.asList(summonerNames));
    }

    

Returns:
the mastery tree
See also:
LoL API Specification
    public MasteryTree getMasteryTree() {
        if(!.) {
            final Set<MasteryDatamasteryData = new HashSet<MasteryData>();
            masteryData.add(.);
            final String json = .getMasteries(masteryData);
            try {
                final JSONObject masteryList = (JSONObject).parse(json);
                final List<Masterymasteries = JSONConverter.getListFromMap(masteryList"data"m -> .getMasteryFromJSON((JSONObject)m));
                for(final Mastery mastery : masteries) {
                    ..put(mastery.IDmastery);
                }
                . = .getMasteryTreeFromJSON((JSONObject)masteryList.get("tree"));
                . = true;
            }
            catch(final ParseException e) {
                throw handleParseException(e);
            }
        }
        return .;
    }

    

Parameters:
ID the match to get information for
Returns:
the match
See also:
LoL API Specification
    public MatchSummary getMatch(final long ID) {
        return getMatch(IDtrue);
    }

    

Parameters:
ID the match to get information for
includeTimeline whether to include the match timeline
Returns:
the match
See also:
LoL API Specification
    public MatchSummary getMatch(final long IDfinal boolean includeTimeline) {
        final String json = .getMatch(IDincludeTimeline);
        try {
            return .getMatchSummaryFromJSON((JSONObject).parse(json));
        }
        catch(final ParseException e) {
            throw handleParseException(e);
        }
    }

    

Parameters:
summonerID the summoner to get information for
Returns:
the summoner's match history
See also:
LoL API Specification
    public List<MatchSummarygetMatchHistory(final long summonerID) {
        return getMatchHistory(summonerIDnullnullnullnull);
    }

    

Parameters:
summonerID the summoner to get information for
beginIndex the begin index to use for fetching games. No more than 15 games will be fetched.
endIndex the end index to use for fetching games. No more than 15 games will be fetched.
Returns:
the summoner's match history
See also:
LoL API Specification
    public List<MatchSummarygetMatchHistory(final long summonerIDfinal Integer beginIndexfinal Integer endIndex) {
        return getMatchHistory(summonerIDnullnullbeginIndexendIndex);
    }

    

Parameters:
summonerID the summoner to get information for
champions which champions to limit this search to
rankedQueues which queues to limit this search to. Any queues other than RANKED_SOLO_5x5, RANKED_TEAM_5x5, and RANKED_TEAM_3x3 will be ignored.
Returns:
the summoner's match history
See also:
LoL API Specification
    public List<MatchSummarygetMatchHistory(final long summonerIDfinal List<Championchampionsfinal List<QueueTyperankedQueues) {
        return getMatchHistory(summonerIDchampionsrankedQueuesnullnull);
    }

    

Parameters:
summonerID the summoner to get information for
champions which champions to limit this search to
rankedQueues which queues to limit this search to. Any queues other than RANKED_SOLO_5x5, RANKED_TEAM_5x5, and RANKED_TEAM_3x3 will be ignored.
beginIndex the begin index to use for fetching games. No more than 15 games will be fetched.
endIndex the end index to use for fetching games. No more than 15 games will be fetched.
Returns:
the summoner's match history
See also:
LoL API Specification
    public List<MatchSummarygetMatchHistory(final long summonerIDfinal List<Championchampionsfinal List<QueueTyperankedQueues,
            final Integer beginIndexfinal Integer endIndex) {
        final List<IntegerchampionIDs = champions == null ? null : champions.stream().map((champ) -> champ.ID).collect(Collectors.toList());
        final String json = .getSummonerMatchHistory(summonerIDchampionIDsrankedQueuesbeginIndexendIndex);
        try {
            return .getMatchHistoryFromJSON((JSONArray)((JSONObject).parse(json)).get("matches"));
        }
        catch(final ParseException e) {
            throw handleParseException(e);
        }
    }

    

Parameters:
summonerName the summoner to get information for
Returns:
the summoner's match history
See also:
LoL API Specification
    public List<MatchSummarygetMatchHistory(final String summonerName) {
        return getMatchHistory(getSummoner(summonerName));
    }

    

Parameters:
summonerName the summoner to get information for
beginIndex the begin index to use for fetching games. No more than 15 games will be fetched.
endIndex the end index to use for fetching games. No more than 15 games will be fetched.
Returns:
the summoner's match history
See also:
LoL API Specification
    public List<MatchSummarygetMatchHistory(final String summonerNamefinal Integer beginIndexfinal Integer endIndex) {
        return getMatchHistory(getSummoner(summonerName), beginIndexendIndex);
    }

    

Parameters:
summonerName the summoner to get information for
champions which champions to limit this search to
rankedQueues which queues to limit this search to. Any queues other than RANKED_SOLO_5x5, RANKED_TEAM_5x5, and RANKED_TEAM_3x3 will be ignored.
Returns:
the summoner's match history
See also:
LoL API Specification
    public List<MatchSummarygetMatchHistory(final String summonerNamefinal List<Championchampionsfinal List<QueueTyperankedQueues) {
        return getMatchHistory(getSummoner(summonerName), championsrankedQueues);
    }

    

Parameters:
summonerName the summoner to get information for
champions which champions to limit this search to
rankedQueues which queues to limit this search to. Any queues other than RANKED_SOLO_5x5, RANKED_TEAM_5x5, and RANKED_TEAM_3x3 will be ignored.
beginIndex the begin index to use for fetching games. No more than 15 games will be fetched.
endIndex the end index to use for fetching games. No more than 15 games will be fetched.
Returns:
the summoner's match history
See also:
LoL API Specification
    public List<MatchSummarygetMatchHistory(final String summonerNamefinal List<Championchampionsfinal List<QueueTyperankedQueues,
            final Integer beginIndexfinal Integer endIndex) {
        return getMatchHistory(getSummoner(summonerName), championsrankedQueuesbeginIndexendIndex);
    }

    

Parameters:
summoner the summoner to get match history for
Returns:
the summoner's match history
See also:
LoL API Specification
    public List<MatchSummarygetMatchHistory(final Summoner summoner) {
        return getMatchHistory(summoner.ID);
    }

    

Parameters:
summoner the summoner to get information for
beginIndex the begin index to use for fetching games. No more than 15 games will be fetched.
endIndex the end index to use for fetching games. No more than 15 games will be fetched.
Returns:
the summoner's match history
See also:
LoL API Specification
    public List<MatchSummarygetMatchHistory(final Summoner summonerfinal Integer beginIndexfinal Integer endIndex) {
        return getMatchHistory(summoner.IDbeginIndexendIndex);
    }

    

Parameters:
summoner the summoner to get information for
champions which champions to limit this search to
rankedQueues which queues to limit this search to. Any queues other than RANKED_SOLO_5x5, RANKED_TEAM_5x5, and RANKED_TEAM_3x3 will be ignored.
Returns:
the summoner's match history
See also:
LoL API Specification
    public List<MatchSummarygetMatchHistory(final Summoner summonerfinal List<Championchampionsfinal List<QueueTyperankedQueues) {
        return getMatchHistory(summoner.IDchampionsrankedQueues);
    }

    

Parameters:
summoner the summoner to get information for
champions which champions to limit this search to
rankedQueues which queues to limit this search to. Any queues other than RANKED_SOLO_5x5, RANKED_TEAM_5x5, and RANKED_TEAM_3x3 will be ignored.
beginIndex the begin index to use for fetching games. No more than 15 games will be fetched.
endIndex the end index to use for fetching games. No more than 15 games will be fetched.
Returns:
the summoner's match history
See also:
LoL API Specification
    public List<MatchSummarygetMatchHistory(final Summoner summonerfinal List<Championchampionsfinal List<QueueTyperankedQueues,
            final Integer beginIndexfinal Integer endIndex) {
        return getMatchHistory(summoner.IDchampionsrankedQueuesbeginIndexendIndex);
    }

    
Entries are by champion name, include "All Champions" for totals.

Parameters:
summonerID the summoner to get information for
Returns:
the summoner's ranked stats
See also:
LoL API Specification
    public Map<StringChampionStatsgetRankedStats(final Long summonerID) {
        return getRankedStats(summonerIDnull);
    }

    
Entries are by champion name, include "All Champions" for totals.

Parameters:
summonerID the summoner to get information for
season the season to get stats for
Returns:
the summoner's ranked stats
See also:
LoL API Specification
    public Map<StringChampionStatsgetRankedStats(final Long summonerIDfinal Season season) {
        if(!.) {
            getChampions(); // Cache in bulk to minimize API calls
        }
        final String json = .getSummonerRankedStatsByID(summonerIDseason);
        JSONObject stats;
        try {
            stats = (JSONObject).parse(json);
        }
        catch(final ParseException e) {
            throw handleParseException(e);
        }
        final JSONArray statList = (JSONArray)stats.get("champions");
        final Map<StringChampionStatschampionStats = new HashMap<StringChampionStats>();
        for(final Object championStatObj : statList) {
            final JSONObject champStat = (JSONObject)championStatObj;
            final ChampionStats championStat = .getChampionStatsFromJSON(champStat);
            if(championStat.champion == null) {
                championStats.put("All Champions"championStat);
            }
            else {
                championStats.put(championStat.champion.namechampionStat);