Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.robrua.orianna.api.core;
  
  import java.util.Arrays;
  import java.util.HashSet;
  import java.util.List;
  import java.util.Map;
  import java.util.Set;
 
 
 public abstract class SummonerAPI {
    

Parameters:
summoners the summoners to get mastery pages for
Returns:
the summoners' mastery pages
 
     public static List<List<MasteryPage>> getMasteryPages(final List<Summonersummoners) {
         final List<LongIDs = new ArrayList<>();
         for(final Summoner summoner : summoners) {
             IDs.add(summoner.getID());
         }
 
         return getMasteryPagesByID(IDs);
     }

    

Parameters:
summoners the summoners to get mastery pages for
Returns:
the summoners' mastery pages
 
     public static List<List<MasteryPage>> getMasteryPages(final Summoner... summoners) {
         final List<LongIDs = new ArrayList<>();
         for(final Summoner summoner : summoners) {
             IDs.add(summoner.getID());
         }
 
         return getMasteryPagesByID(IDs);
     }

    

Parameters:
summoner the summoner to get mastery pages for
Returns:
the summoner's mastery pages
 
     public static List<MasteryPagegetMasteryPages(final Summoner summoner) {
         return getMasteryPagesByID(summoner.getID());
     }

    

Parameters:
summonerIDs the IDs of the summoners to get mastery pages for
Returns:
the summoners' mastery pages
 
     public static List<List<MasteryPage>> getMasteryPagesByID(final List<LongsummonerIDs) {
         if(summonerIDs.isEmpty()) {
             return Collections.emptyList();
         }
 
         final List<List<MasteryPage>> pages = new ArrayList<>();
         final Set<LongmasteryIDs = new HashSet<>();
         for(final List<Longget : Utils.breakUpList(summonerIDs, 40)) {
             final Map<LongMasteryPagespgs = BaseRiotAPI.getSummonersMasteries(get);
             for(final Long ID : get) {
                 final MasteryPages pg = pgs.get(ID);
                 final List<MasteryPageforOne = new ArrayList<>(pg.getPages().size());
                 for(final com.robrua.orianna.type.dto.summoner.MasteryPage p : pg.getPages()) {
                     forOne.add(new MasteryPage(p));
                 }
 
                 pages.add(Collections.unmodifiableList(forOne));
                 masteryIDs.addAll(pg.getMasteryIDs());
             }
         }
 
         if(. == .) {
             RiotAPI.getMasteries(new ArrayList<>(masteryIDs));
         }
 
         return Collections.unmodifiableList(pages);
     }

    

Parameters:
summonerIDs the IDs of the summoners to get mastery pages for
Returns:
the summoners' mastery pages
 
     public static List<List<MasteryPage>> getMasteryPagesByID(final long... summonerIDs) {
         return getMasteryPagesByID(Utils.convert(summonerIDs));
     }

    

Parameters:
summonerID the ID of the summoner to get mastery pages for
Returns:
the summoner's mastery pages
    public static List<MasteryPagegetMasteryPagesByID(final long summonerID) {
        return getMasteryPagesByID(new long[] {summonerID}).get(0);
    }

    

Parameters:
summonerNames the names of the summoners to get mastery pages for
Returns:
the summoners' mastery pages
    public static List<List<MasteryPage>> getMasteryPagesByName(final List<StringsummonerNames) {
        return getMasteryPages(getSummonersByName(summonerNames));
    }

    

Parameters:
summonerNames the names of the summoners to get mastery pages for
Returns:
the summoners' mastery pages
    public static List<List<MasteryPage>> getMasteryPagesByName(final String... summonerNames) {
        return getMasteryPages(getSummonersByName(summonerNames));
    }

    

Parameters:
summonerName the name of the summoner to get mastery pages for
Returns:
the summoner's mastery pages
    public static List<MasteryPagegetMasteryPagesByName(final String summonerName) {
        return getMasteryPages(getSummonerByName(summonerName));
    }

    

Parameters:
summoners the summoners to get rune pages for
Returns:
the summoners' rune pages
    public static List<List<RunePage>> getRunePages(final List<Summonersummoners) {
        final List<LongIDs = new ArrayList<>();
        for(final Summoner summoner : summoners) {
            IDs.add(summoner.getID());
        }
        return getRunePagesByID(IDs);
    }

    

Parameters:
summoners the summoners to get rune pages for
Returns:
the summoners' rune pages
    public static List<List<RunePage>> getRunePages(final Summoner... summoners) {
        final List<LongIDs = new ArrayList<>();
        for(final Summoner summoner : summoners) {
            IDs.add(summoner.getID());
        }
        return getRunePagesByID(IDs);
    }

    

Parameters:
summoner the summoner to get rune pages for
Returns:
the summoner's rune pages
    public static List<RunePagegetRunePages(final Summoner summoner) {
        return getRunePagesByID(summoner.getID());
    }

    

Parameters:
summonerIDs the IDs of the summoners to get rune pages for
Returns:
the summoners' rune pages
    public static List<List<RunePage>> getRunePagesByID(final List<LongsummonerIDs) {
        if(summonerIDs.isEmpty()) {
            return Collections.emptyList();
        }
        final List<List<RunePage>> pages = new ArrayList<>();
        final Set<LongruneIDs = new HashSet<>();
        for(final List<Longget : Utils.breakUpList(summonerIDs, 40)) {
            final Map<LongRunePagespgs = BaseRiotAPI.getSummonersRunes(get);
            for(final Long ID : get) {
                final RunePages pg = pgs.get(ID);
                final List<RunePageforOne = new ArrayList<>(pg.getPages().size());
                for(final com.robrua.orianna.type.dto.summoner.RunePage p : pg.getPages()) {
                    forOne.add(new RunePage(p));
                }
                pages.add(Collections.unmodifiableList(forOne));
                runeIDs.addAll(pg.getRuneIDs());
            }
        }
        if(. == .) {
            RiotAPI.getRunes(new ArrayList<>(runeIDs));
        }
        return Collections.unmodifiableList(pages);
    }

    

Parameters:
summonerIDs the IDs of the summoners to get rune pages for
Returns:
the summoners' rune pages
    public static List<List<RunePage>> getRunePagesByID(final long... summonerIDs) {
        return getRunePagesByID(Utils.convert(summonerIDs));
    }

    

Parameters:
summonerID the ID of the summoner to get rune pages for
Returns:
the summoner's rune pages
    public static List<RunePagegetRunePagesByID(final long summonerID) {
        return getRunePagesByID(new long[] {summonerID}).get(0);
    }

    

Parameters:
summonerNames the names of the summoners to get rune pages for
Returns:
the summoners' rune pages
    public static List<List<RunePage>> getRunePagesByName(final List<StringsummonerNames) {
        return getRunePages(getSummonersByName(summonerNames));
    }

    

Parameters:
summonerNames the names of the summoners to get rune pages for
Returns:
the summoners' rune pages
    public static List<List<RunePage>> getRunePagesByName(final String... summonerNames) {
        return getRunePages(getSummonersByName(summonerNames));
    }

    

Parameters:
summonerName the name of the summoner to get rune pages for
Returns:
the summoner's rune pages
    public static List<RunePagegetRunePagesByName(final String summonerName) {
        return getRunePages(getSummonerByName(summonerName));
    }

    

Parameters:
ID the ID of the summoner to get
Returns:
the summoner
    public static Summoner getSummonerByID(final long ID) {
        return getSummonersByID(ID).get(0);
    }

    

Parameters:
name the name of the summoner to get
Returns:
the summoners
    public static Summoner getSummonerByName(final String name) {
        return getSummonersByName(name).get(0);
    }

    

Parameters:
ID the ID of the summoner to get the names of
Returns:
the summoner's name
    public static String getSummonerName(final long ID) {
        return getSummonersNames(ID).get(0);
    }

    

Parameters:
IDs the IDs of the summoners to get
Returns:
the summoners
    public synchronized static List<SummonergetSummonersByID(final List<LongIDs) {
        if(IDs.isEmpty()) {
            return Collections.emptyList();
        }
        final List<Summonersummoners = ..get(Summoner.classIDs);
        final List<LongtoGet = new ArrayList<>();
        final List<Integerindex = new ArrayList<>();
        for(int i = 0; i < IDs.size(); i++) {
            if(summoners.get(i) == null) {
                toGet.add(IDs.get(i));
                index.add(i);
            }
        }
        if(toGet.isEmpty()) {
            return summoners;
        }
        final List<Summonergotten = new ArrayList<>();
        final List<Stringnames = new ArrayList<>();
        for(final List<Longget : Utils.breakUpList(toGet, 40)) {
            final Map<Longcom.robrua.orianna.type.dto.summoner.Summonersums = BaseRiotAPI.getSummonersByID(get);
            for(final Long ID : get) {
                gotten.add(new Summoner(sums.get(ID)));
                names.add(sums.get(ID).getName());
            }
        }
        ..store(gottentoGetfalse);
        ..store(gottennamesfalse);
        int count = 0;
        for(final Integer id : index) {
            summoners.set(idgotten.get(count++));
        }
        return Collections.unmodifiableList(summoners);
    }

    

Parameters:
IDs the IDs of the summoners to get
Returns:
the summoners
    public static List<SummonergetSummonersByID(final long... IDs) {
        return getSummonersByID(Utils.convert(IDs));
    }

    

Parameters:
names the names of the summoners to get
Returns:
the summoners
    public synchronized static List<SummonergetSummonersByName(final List<Stringnames) {
        if(names.isEmpty()) {
            return Collections.emptyList();
        }
        final List<Summonersummoners = ..get(Summoner.classnames);
        final List<StringtoGet = new ArrayList<>();
        final List<Integerindex = new ArrayList<>();
        for(int i = 0; i < names.size(); i++) {
            if(summoners.get(i) == null) {
                toGet.add(names.get(i));
                index.add(i);
            }
        }
        if(toGet.isEmpty()) {
            return summoners;
        }
        final List<Summonergotten = new ArrayList<>();
        final List<StringIDs = new ArrayList<>();
        for(final List<Stringget : Utils.breakUpList(toGet, 40)) {
            final Map<Stringcom.robrua.orianna.type.dto.summoner.Summonersums = BaseRiotAPI.getSummonersByName(get);
            for(final String name : get) {
                final String std = standardize(name);
                gotten.add(new Summoner(sums.get(std)));
                if(sums.get(std) == null) {
                    IDs.add("[" + null + "]");
                }
                else {
                    IDs.add("[" + sums.get(std).getId() + "]");
                }
            }
        }
        ..store(gottentoGetfalse);
        ..store(gottenIDsfalse);
        int count = 0;
        for(final Integer id : index) {
            summoners.set(idgotten.get(count++));
        }
        return Collections.unmodifiableList(summoners);
    }

    

Parameters:
names the names of the summoners to get
Returns:
the summoners
    public static List<SummonergetSummonersByName(final String... names) {
        return getSummonersByName(Arrays.asList(names));
    }

    

Parameters:
IDs the IDs of the summoners to get the names of
Returns:
the summoners' names
    public synchronized static List<StringgetSummonersNames(final List<LongIDs) {
        if(IDs.isEmpty()) {
            return Collections.emptyList();
        }
        final List<Summonersummoners = ..get(Summoner.classIDs);
        final List<Stringnames = new ArrayList<>(summoners.size());
        for(final Summoner summoner : summoners) {
            if(summoner != null) {
                names.add(summoner.getName());
            }
            else {
                names.add(null);
            }
        }
        final List<LongtoGet = new ArrayList<>();
        final List<Integerindex = new ArrayList<>();
        for(int i = 0; i < IDs.size(); i++) {
            if(summoners.get(i) == null) {
                toGet.add(IDs.get(i));
                index.add(i);
            }
        }
        if(toGet.isEmpty()) {
            return names;
        }
        final List<Stringgotten = new ArrayList<>();
        for(final List<Longget : Utils.breakUpList(toGet, 40)) {
            final Map<LongStringsums = BaseRiotAPI.getSummonersNames(get);
            for(final Long ID : get) {
                gotten.add(sums.get(ID));
            }
        }
        int count = 0;
        for(final Integer id : index) {
            names.set(idgotten.get(count++));
        }
        return Collections.unmodifiableList(names);
    }

    

Parameters:
IDs the IDs of the summoners to get the names of
Returns:
the summoners' names
    public static List<StringgetSummonersNames(final long... IDs) {
        return getSummonersNames(Utils.convert(IDs));
    }

    
Standardizes a summoner name, which is the summoner name in all lower case and with spaces removed (per the API spec)

Parameters:
summonerName the name to standardize
Returns:
the standardized summoner name
    private static String standardize(final String summonerName) {
        return summonerName.replaceAll(" """).toLowerCase();
    }
New to GrepCode? Check out our FAQ X