All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.robrua.orianna.api.dto.AsyncBaseRiotAPI Maven / Gradle / Ivy

There is a newer version: 2.4.5
Show newest version
package com.robrua.orianna.api.dto;

import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Map;

import com.robrua.orianna.type.api.Action;
import com.robrua.orianna.type.api.RateLimit;
import com.robrua.orianna.type.core.common.QueueType;
import com.robrua.orianna.type.core.common.Region;
import com.robrua.orianna.type.core.common.Season;
import com.robrua.orianna.type.dto.currentgame.CurrentGameInfo;
import com.robrua.orianna.type.dto.featuredgames.FeaturedGames;
import com.robrua.orianna.type.dto.game.RecentGames;
import com.robrua.orianna.type.dto.league.League;
import com.robrua.orianna.type.dto.match.MatchDetail;
import com.robrua.orianna.type.dto.matchhistory.PlayerHistory;
import com.robrua.orianna.type.dto.staticdata.Item;
import com.robrua.orianna.type.dto.staticdata.ItemList;
import com.robrua.orianna.type.dto.staticdata.LanguageStrings;
import com.robrua.orianna.type.dto.staticdata.MapData;
import com.robrua.orianna.type.dto.staticdata.Mastery;
import com.robrua.orianna.type.dto.staticdata.MasteryList;
import com.robrua.orianna.type.dto.staticdata.Realm;
import com.robrua.orianna.type.dto.staticdata.Rune;
import com.robrua.orianna.type.dto.staticdata.RuneList;
import com.robrua.orianna.type.dto.staticdata.SummonerSpell;
import com.robrua.orianna.type.dto.staticdata.SummonerSpellList;
import com.robrua.orianna.type.dto.stats.PlayerStatsSummaryList;
import com.robrua.orianna.type.dto.stats.RankedStats;
import com.robrua.orianna.type.dto.status.Shard;
import com.robrua.orianna.type.dto.status.ShardStatus;
import com.robrua.orianna.type.dto.summoner.MasteryPages;
import com.robrua.orianna.type.dto.summoner.RunePages;
import com.robrua.orianna.type.dto.summoner.Summoner;
import com.robrua.orianna.type.dto.team.Team;
import com.robrua.orianna.type.exception.APIException;

/**
 * Queries the LoL REST
 * API asynchronously
 *
 * @author Rob Rua (FatalElement - NA) ([email protected])
 */
public class AsyncBaseRiotAPI {
    /**
     * @param action
     *            what to do with the challenger league
     * @param queueType
     *            the queue type to get the challenger league for
     * @see Riot
     *      API Specification
     */
    public static void getChallenger(final Action action, final QueueType queueType) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    LeagueAPI.getChallenger(queueType);
                }
                else {
                    try {
                        action.perform(LeagueAPI.getChallenger(queueType));
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the champion
     * @param ID
     *            the champion's ID
     * @see Riot
     *      API Specification
     */
    public static void getChampion(final Action action, final long ID) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    StaticDataAPI.getChampion(ID);
                }
                else {
                    try {
                        action.perform(StaticDataAPI.getChampion(ID));
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the list all of champions
     * @see Riot
     *      API Specification
     */
    public static void getChampions(final Action action) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    StaticDataAPI.getChampions();
                }
                else {
                    try {
                        action.perform(StaticDataAPI.getChampions());
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the champion
     * @param ID
     *            the ID of the champion to look up
     * @see Riot
     *      API Specification
     */
    public static void getChampionStatus(final Action action, final long ID) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    ChampionAPI.getChampionStatus(ID);
                }
                else {
                    try {
                        action.perform(ChampionAPI.getChampionStatus(ID));
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with all champions
     * @param freeToPlay
     *            whether to only return free champions
     * @see Riot
     *      API Specification
     */
    public static void getChampionStatuses(final Action action, final boolean freeToPlay) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    ChampionAPI.getChampionStatuses(freeToPlay);
                }
                else {
                    try {
                        action.perform(ChampionAPI.getChampionStatuses(freeToPlay));
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the summoner's current game
     * @param summonerID
     *            summoner to look up current game for
     * @see Riot
     *      API Specification
     */
    public static void getCurrentGame(final Action action, final long summonerID) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    CurrentGameAPI.getCurrentGame(summonerID);
                }
                else {
                    try {
                        action.perform(CurrentGameAPI.getCurrentGame(summonerID));
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the featured games
     * @see Riot
     *      API Specification
     */
    public static void getFeaturedGames(final Action action) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    FeaturedGamesAPI.getFeaturedGames();
                }
                else {
                    try {
                        action.perform(FeaturedGamesAPI.getFeaturedGames());
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the item
     * @param ID
     *            the item's ID
     * @see Riot
     *      API Specification
     */
    public static void getItem(final Action action, final long ID) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    StaticDataAPI.getItem(ID);
                }
                else {
                    try {
                        action.perform(StaticDataAPI.getItem(ID));
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the list of all items
     * @see Riot
     *      API Specification
     */
    public static void getItems(final Action action) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    StaticDataAPI.getItems();
                }
                else {
                    try {
                        action.perform(StaticDataAPI.getItems());
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the languages
     * @see Riot
     *      API Specification
     */
    public static void getLanguages(final Action> action) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    StaticDataAPI.getLanguages();
                }
                else {
                    try {
                        action.perform(StaticDataAPI.getLanguages());
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the language strings
     * @see Riot
     *      API Specification
     */
    public static void getLanguageStrings(final Action action) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    StaticDataAPI.getLanguageStrings();
                }
                else {
                    try {
                        action.perform(StaticDataAPI.getLanguageStrings());
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the map information
     * @see Riot
     *      API Specification
     */
    public static void getMapInformation(final Action action) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    StaticDataAPI.getMapInformation();
                }
                else {
                    try {
                        action.perform(StaticDataAPI.getMapInformation());
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the list of all masteries
     * @see Riot
     *      API Specification
     */
    public static void getMasteries(final Action action) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    StaticDataAPI.getMasteries();
                }
                else {
                    try {
                        action.perform(StaticDataAPI.getMasteries());
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the mastery
     * @param ID
     *            the mastery's ID
     * @see Riot
     *      API Specification
     */
    public static void getMastery(final Action action, final long ID) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    StaticDataAPI.getMastery(ID);
                }
                else {
                    try {
                        action.perform(StaticDataAPI.getMastery(ID));
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the match
     * @param ID
     *            the ID of the match to look up
     * @see Riot
     *      API Specification
     */
    public static void getMatch(final Action action, final long ID) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    MatchAPI.getMatch(ID);
                }
                else {
                    try {
                        action.perform(MatchAPI.getMatch(ID));
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the match history for that summoner Gets the
     *            15 most recent matches for the summoner
     *
     * @param summonerID
     *            the ID of the summoner to get match history for
     * @see Riot
     *      API Specification
     */
    public static void getMatchHistory(final Action action, final long summonerID) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    MatchHistoryAPI.getMatchHistory(summonerID);
                }
                else {
                    try {
                        action.perform(MatchHistoryAPI.getMatchHistory(summonerID));
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the match history for that summoner Gets the
     *            15 most recent matches after beginIndex for the summoner
     *
     * @param summonerID
     *            the ID of the summoner to get match history for
     * @param beginIndex
     *            the game index to start from
     * @see Riot
     *      API Specification
     */
    public static void getMatchHistory(final Action action, final long summonerID, final int beginIndex) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    MatchHistoryAPI.getMatchHistory(summonerID, beginIndex);
                }
                else {
                    try {
                        action.perform(MatchHistoryAPI.getMatchHistory(summonerID, beginIndex));
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the match history for that summoner Gets the
     *            15 most recent matches after beginIndex for the summoner
     *
     * @param summonerID
     *            the ID of the summoner to get match history for
     * @param beginIndex
     *            the game index to start from
     * @param championIDs
     *            the champions to limit games to
     * @see Riot
     *      API Specification
     */
    public static void getMatchHistory(final Action action, final long summonerID, final int beginIndex, final List championIDs) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    MatchHistoryAPI.getMatchHistory(summonerID, beginIndex, championIDs);
                }
                else {
                    try {
                        action.perform(MatchHistoryAPI.getMatchHistory(summonerID, beginIndex, championIDs));
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the match history for that summoner Gets the
     *            15 most recent matches after beginIndex for the summoner
     *
     * @param summonerID
     *            the ID of the summoner to get match history for
     * @param beginIndex
     *            the game index to start from
     * @param queueType
     *            the queue type to limit games to (only ranked queues)
     * @see Riot
     *      API Specification
     */
    public static void getMatchHistory(final Action action, final long summonerID, final int beginIndex, final QueueType queueType) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    MatchHistoryAPI.getMatchHistory(summonerID, beginIndex, queueType);
                }
                else {
                    try {
                        action.perform(MatchHistoryAPI.getMatchHistory(summonerID, beginIndex, queueType));
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the match history for that summoner Gets the
     *            15 most recent matches after beginIndex for the summoner
     *
     * @param summonerID
     *            the ID of the summoner to get match history for
     * @param beginIndex
     *            the game index to start from
     * @param queueType
     *            the queue type to limit games to (only ranked queues)
     * @param championIDs
     *            the champions to limit games to
     * @see Riot
     *      API Specification
     */
    public static void getMatchHistory(final Action action, final long summonerID, final int beginIndex, final QueueType queueType,
            final List championIDs) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    MatchHistoryAPI.getMatchHistory(summonerID, beginIndex, queueType, championIDs);
                }
                else {
                    try {
                        action.perform(MatchHistoryAPI.getMatchHistory(summonerID, beginIndex, queueType, championIDs));
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the match history for that summoner Gets the
     *            15 most recent matches for the summoner
     *
     * @param summonerID
     *            the ID of the summoner to get match history for
     * @param championIDs
     *            the champions to limit games to
     * @see Riot
     *      API Specification
     */
    public static void getMatchHistory(final Action action, final long summonerID, final List championIDs) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    MatchHistoryAPI.getMatchHistory(summonerID, championIDs);
                }
                else {
                    try {
                        action.perform(MatchHistoryAPI.getMatchHistory(summonerID, championIDs));
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the match history for that summoner Gets the
     *            15 most recent matches for the summoner
     *
     * @param summonerID
     *            the ID of the summoner to get match history for
     * @param queueType
     *            the queue type to limit games to (only ranked queues)
     * @see Riot
     *      API Specification
     */
    public static void getMatchHistory(final Action action, final long summonerID, final QueueType queueType) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    MatchHistoryAPI.getMatchHistory(summonerID, queueType);
                }
                else {
                    try {
                        action.perform(MatchHistoryAPI.getMatchHistory(summonerID, queueType));
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the match history for that summoner Gets the
     *            15 most recent matches for the summoner
     *
     * @param summonerID
     *            the ID of the summoner to get match history for
     * @param queueType
     *            the queue type to limit games to (only ranked queues)
     * @param championIDs
     *            the champions to limit games to
     * @see Riot
     *      API Specification
     */
    public static void getMatchHistory(final Action action, final long summonerID, final QueueType queueType, final List championIDs) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    MatchHistoryAPI.getMatchHistory(summonerID, queueType, championIDs);
                }
                else {
                    try {
                        action.perform(MatchHistoryAPI.getMatchHistory(summonerID, queueType, championIDs));
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the ranked stats for that summoner
     * @param summonerID
     *            the ID of the summoner to get ranked stats for
     * @see Riot
     *      API Specification
     */
    public static void getRankedStats(final Action action, final long summonerID) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    StatsAPI.getRankedStats(summonerID);
                }
                else {
                    try {
                        action.perform(StatsAPI.getRankedStats(summonerID));
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the ranked stats for that summoner
     * @param summonerID
     *            the ID of the summoner to get ranked stats for
     * @param season
     *            the season to get stats for
     * @see Riot
     *      API Specification
     */
    public static void getRankedStats(final Action action, final long summonerID, final Season season) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    StatsAPI.getRankedStats(summonerID, season);
                }
                else {
                    try {
                        action.perform(StatsAPI.getRankedStats(summonerID, season));
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the realm
     * @see Riot
     *      API Specification
     */
    public static void getRealm(final Action action) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    StaticDataAPI.getRealm();
                }
                else {
                    try {
                        action.perform(StaticDataAPI.getRealm());
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the summoner's recent games
     * @param summonerID
     *            the ID of the summoner to look up recent games for
     * @see Riot
     *      API Specification
     */
    public static void getRecentGames(final Action action, final long summonerID) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    GameAPI.getRecentGames(summonerID);
                }
                else {
                    try {
                        action.perform(GameAPI.getRecentGames(summonerID));
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the rune
     * @param ID
     *            the rune's ID
     * @see Riot
     *      API Specification
     */
    public static void getRune(final Action action, final long ID) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    StaticDataAPI.getRune(ID);
                }
                else {
                    try {
                        action.perform(StaticDataAPI.getRune(ID));
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the list of all runes
     * @see Riot
     *      API Specification
     */
    public static void getRunes(final Action action) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    StaticDataAPI.getRunes();
                }
                else {
                    try {
                        action.perform(StaticDataAPI.getRunes());
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the shard
     * @param region
     *            the region's shard to get
     * @see Riot
     *      API Specification
     */
    public static void getShard(final Action action, final Region region) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    StatusAPI.getShard(region);
                }
                else {
                    try {
                        action.perform(StatusAPI.getShard(region));
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the list of all shards
     * @see Riot
     *      API Specification
     */
    public static void getShards(final Action> action) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    StatusAPI.getShards();
                }
                else {
                    try {
                        action.perform(StatusAPI.getShards());
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the stats for that summoner
     * @param summonerID
     *            the ID of the summoner to get stats for
     * @see Riot
     *      API Specification
     */
    public static void getStats(final Action action, final long summonerID) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    StatsAPI.getStats(summonerID);
                }
                else {
                    try {
                        action.perform(StatsAPI.getStats(summonerID));
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the stats for that summoner
     * @param summonerID
     *            the ID of the summoner to get stats for
     * @param season
     *            the season to get stats for
     * @see Riot
     *      API Specification
     */
    public static void getStats(final Action action, final long summonerID, final Season season) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    StatsAPI.getStats(summonerID, season);
                }
                else {
                    try {
                        action.perform(StatsAPI.getStats(summonerID, season));
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the summoners' league entries
     * @param summonerIDs
     *            the summoners to get league entries for
     * @see Riot
     *      API Specification
     */
    public static void getSummonerLeagueEntries(final Action>> action, final List summonerIDs) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    LeagueAPI.getSummonerLeagueEntries(summonerIDs);
                }
                else {
                    try {
                        action.perform(LeagueAPI.getSummonerLeagueEntries(summonerIDs));
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the summoners' league entries
     * @param summonerIDs
     *            the summoners to get league entries for
     * @see Riot
     *      API Specification
     */
    public static void getSummonerLeagueEntries(final Action>> action, final long... summonerIDs) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    LeagueAPI.getSummonerLeagueEntries(summonerIDs);
                }
                else {
                    try {
                        action.perform(LeagueAPI.getSummonerLeagueEntries(summonerIDs));
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the summoners' league
     * @param summonerIDs
     *            the summoners to get leagues for
     * @see Riot
     *      API Specification
     */
    public static void getSummonerLeagues(final Action>> action, final List summonerIDs) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    LeagueAPI.getSummonerLeagues(summonerIDs);
                }
                else {
                    try {
                        action.perform(LeagueAPI.getSummonerLeagues(summonerIDs));
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the summoners' league
     * @param summonerIDs
     *            the summoners to get leagues for
     * @see Riot
     *      API Specification
     */
    public static void getSummonerLeagues(final Action>> action, final long... summonerIDs) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    LeagueAPI.getSummonerLeagues(summonerIDs);
                }
                else {
                    try {
                        action.perform(LeagueAPI.getSummonerLeagues(summonerIDs));
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the summoners
     * @param summonerIDs
     *            the IDs of the summoners to get
     * @see Riot
     *      API Specification
     */
    public static void getSummonersByID(final Action> action, final List summonerIDs) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    SummonerAPI.getSummonersByID(summonerIDs);
                }
                else {
                    try {
                        action.perform(SummonerAPI.getSummonersByID(summonerIDs));
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the summoners
     * @param summonerIDs
     *            the IDs of the summoners to get
     * @see Riot
     *      API Specification
     */
    public static void getSummonersByID(final Action> action, final long... summonerIDs) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    SummonerAPI.getSummonersByID(summonerIDs);
                }
                else {
                    try {
                        action.perform(SummonerAPI.getSummonersByID(summonerIDs));
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the summoners
     * @param summonerNames
     *            the names of the summoners to get
     * @see Riot
     *      API Specification
     */
    public static void getSummonersByName(final Action> action, final List summonerNames) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    SummonerAPI.getSummonersByName(summonerNames);
                }
                else {
                    try {
                        action.perform(SummonerAPI.getSummonersByName(summonerNames));
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the summoners
     * @param summonerNames
     *            the names of the summoners to get
     * @see Riot
     *      API Specification
     */
    public static void getSummonersByName(final Action> action, final String... summonerNames) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    SummonerAPI.getSummonersByName(summonerNames);
                }
                else {
                    try {
                        action.perform(SummonerAPI.getSummonersByName(summonerNames));
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the summoners' masteries
     * @param summonerIDs
     *            the IDs of the summoners to get masteries for
     * @see Riot
     *      API Specification
     */
    public static void getSummonersMasteries(final Action> action, final List summonerIDs) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    SummonerAPI.getSummonersMasteries(summonerIDs);
                }
                else {
                    try {
                        action.perform(SummonerAPI.getSummonersMasteries(summonerIDs));
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the summoners' masteries
     * @param summonerIDs
     *            the IDs of the summoners to get masteries for
     * @see Riot
     *      API Specification
     */
    public static void getSummonersMasteries(final Action> action, final long... summonerIDs) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    SummonerAPI.getSummonersMasteries(summonerIDs);
                }
                else {
                    try {
                        action.perform(SummonerAPI.getSummonersMasteries(summonerIDs));
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the summoners' names
     * @param summonerIDs
     *            the IDs of the summoners to get names of
     * @see Riot
     *      API Specification
     */
    public static void getSummonersNames(final Action> action, final List summonerIDs) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    SummonerAPI.getSummonersNames(summonerIDs);
                }
                else {
                    try {
                        action.perform(SummonerAPI.getSummonersNames(summonerIDs));
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the summoners' names
     * @param summonerIDs
     *            the IDs of the summoners to get names of
     * @see Riot
     *      API Specification
     */
    public static void getSummonersNames(final Action> action, final long... summonerIDs) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    SummonerAPI.getSummonersNames(summonerIDs);
                }
                else {
                    try {
                        action.perform(SummonerAPI.getSummonersNames(summonerIDs));
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the summoner spell
     * @param ID
     *            the summoner spell's ID
     * @see Riot
     *      API Specification
     */
    public static void getSummonerSpell(final Action action, final long ID) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    StaticDataAPI.getSummonerSpell(ID);
                }
                else {
                    try {
                        action.perform(StaticDataAPI.getSummonerSpell(ID));
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the list of all summoner spells
     * @see Riot
     *      API Specification
     */
    public static void getSummonerSpells(final Action action) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    StaticDataAPI.getSummonerSpells();
                }
                else {
                    try {
                        action.perform(StaticDataAPI.getSummonerSpells());
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the summoners' runes
     * @param summonerIDs
     *            the IDs of the summoners to get runes for
     * @see Riot
     *      API Specification
     */
    public static void getSummonersRunes(final Action> action, final List summonerIDs) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    SummonerAPI.getSummonersRunes(summonerIDs);
                }
                else {
                    try {
                        action.perform(SummonerAPI.getSummonersRunes(summonerIDs));
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the summoners' runes
     * @param summonerIDs
     *            the IDs of the summoners to get runes for
     * @see Riot
     *      API Specification
     */
    public static void getSummonersRunes(final Action> action, final long... summonerIDs) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    SummonerAPI.getSummonersRunes(summonerIDs);
                }
                else {
                    try {
                        action.perform(SummonerAPI.getSummonersRunes(summonerIDs));
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the team's leagues
     * @param teamIDs
     *            the summoners to get leagues for
     * @see Riot
     *      API Specification
     */
    public static void getTeamLeagueEntries(final Action>> action, final List teamIDs) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    LeagueAPI.getTeamLeagueEntries(teamIDs);
                }
                else {
                    try {
                        action.perform(LeagueAPI.getTeamLeagueEntries(teamIDs));
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the team's leagues
     * @param teamIDs
     *            the summoners to get leagues for
     * @see Riot
     *      API Specification
     */
    public static void getTeamLeagueEntries(final Action>> action, final String... teamIDs) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    LeagueAPI.getTeamLeagueEntries(teamIDs);
                }
                else {
                    try {
                        action.perform(LeagueAPI.getTeamLeagueEntries(teamIDs));
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the team's leagues
     * @param teamIDs
     *            the summoners to get leagues for
     * @see Riot
     *      API Specification
     */
    public static void getTeamLeagues(final Action>> action, final List teamIDs) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    LeagueAPI.getTeamLeagues(teamIDs);
                }
                else {
                    try {
                        action.perform(LeagueAPI.getTeamLeagues(teamIDs));
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the team's leagues
     * @param teamIDs
     *            the summoners to get leagues for
     * @see Riot
     *      API Specification
     */
    public static void getTeamLeagues(final Action>> action, final String... teamIDs) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    LeagueAPI.getTeamLeagues(teamIDs);
                }
                else {
                    try {
                        action.perform(LeagueAPI.getTeamLeagues(teamIDs));
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the teams
     * @param IDs
     *            the IDs of the teams
     * @see Riot
     *      API Specification
     */
    public static void getTeamsByID(final Action> action, final List IDs) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    TeamAPI.getTeamsByID(IDs);
                }
                else {
                    try {
                        action.perform(TeamAPI.getTeamsByID(IDs));
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the teams
     * @param IDs
     *            the IDs of the teams
     * @see Riot
     *      API Specification
     */
    public static void getTeamsByID(final Action> action, final String... IDs) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    TeamAPI.getTeamsByID(IDs);
                }
                else {
                    try {
                        action.perform(TeamAPI.getTeamsByID(IDs));
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the summoners' teams
     * @param summonerIDs
     *            the IDs of the summoners to get teams for
     * @see Riot
     *      API Specification
     */
    public static void getTeamsBySummoner(final Action>> action, final List summonerIDs) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    TeamAPI.getTeamsBySummoner(summonerIDs);
                }
                else {
                    try {
                        action.perform(TeamAPI.getTeamsBySummoner(summonerIDs));
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the summoners' teams
     * @param summonerIDs
     *            the IDs of the summoners to get teams for
     * @see Riot
     *      API Specification
     */
    public static void getTeamsBySummoner(final Action>> action, final long... summonerIDs) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    TeamAPI.getTeamsBySummoner(summonerIDs);
                }
                else {
                    try {
                        action.perform(TeamAPI.getTeamsBySummoner(summonerIDs));
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the match IDs
     * @param bucketStartTime
     *            the start time for the 5-minute bucket to query
     * @see Riot
     *      API Specification
     */
    public static void getURFMatchIDs(final Action> action, final Date bucketStartTime) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    ChallengeAPI.getURFMatchIDs(bucketStartTime);
                }
                else {
                    try {
                        action.perform(ChallengeAPI.getURFMatchIDs(bucketStartTime));
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the match IDs
     * @param bucketStartTime
     *            the start time for the 5-minute bucket to query (in epoch
     *            seconds)
     * @see Riot
     *      API Specification
     */
    public static void getURFMatchIDs(final Action> action, final long bucketStartTime) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    ChallengeAPI.getURFMatchIDs(bucketStartTime);
                }
                else {
                    try {
                        action.perform(ChallengeAPI.getURFMatchIDs(bucketStartTime));
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * @param action
     *            what to do with the versions
     * @see Riot
     *      API Specification
     */
    public static void getVersions(final Action> action) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                if(action == null) {
                    StaticDataAPI.getVersions();
                }
                else {
                    try {
                        action.perform(StaticDataAPI.getVersions());
                    }
                    catch(final APIException e) {
                        action.handle(e);
                    }
                }
            }
        }).start();
    }

    /**
     * If turned on, prints the URI of calls made to stdout
     *
     * @param on
     *            whether to print the URI of calls to stdout
     */
    public static void printCalls(final boolean on) {
        BaseRiotAPI.printCalls(on);
    }

    /**
     * Removes any set proxy
     */
    public static void removeProxy() {
        BaseRiotAPI.removeProxy();
    }

    /**
     * Sets the API Key to use for queries
     *
     * @param newAPIKey
     *            the API Key to use for queries
     */
    public static void setAPIKey(final String newAPIKey) {
        BaseRiotAPI.setAPIKey(newAPIKey);
    }

    /**
     * Sets the server mirror to hit for queries
     *
     * @param newMirror
     *            the server mirror to hit for queries
     */
    public static void setMirror(final Region newMirror) {
        BaseRiotAPI.setMirror(newMirror);
    }

    /**
     * Sets the proxy to access the API through
     *
     * @param IP
     *            the IP address of the proxy server
     * @param port
     *            the working port for the proxy server
     */
    public static void setProxy(final String IP, final int port) {
        BaseRiotAPI.setProxy(IP, port);
    }

    /**
     * Sets multiple new rate limits for the API, removing any old ones
     *
     * @param limits
     *            the rate limits to apply
     */
    public static void setRateLimit(final Collection limits) {
        BaseRiotAPI.setRateLimit(limits);
    }

    /**
     * Sets a new rate limit for the API, removing any old ones
     *
     * @param callsPerEpoch
     *            the number of calls allowed in each epoch
     * @param secondsPerEpoch
     *            the number of seconds in each epoch
     */
    public static void setRateLimit(final int callsPerEpoch, final int secondsPerEpoch) {
        BaseRiotAPI.setRateLimit(callsPerEpoch, secondsPerEpoch);
    }

    /**
     * Sets a new rate limit for the API, removing any old ones
     *
     * @param limit
     *            the rate limit
     */
    public static void setRateLimit(final RateLimit limit) {
        BaseRiotAPI.setRateLimit(limit);
    }

    /**
     * Sets multiple new rate limits for the API, removing any old ones
     *
     * @param limits
     *            the rate limits to apply
     */
    public static void setRateLimit(final RateLimit... limits) {
        BaseRiotAPI.setRateLimit(limits);
    }

    /**
     * Sets the region to get information from the API for
     *
     * @param newRegion
     *            the region to get information from the API for
     */
    public static void setRegion(final Region newRegion) {
        BaseRiotAPI.setRegion(newRegion);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy