Huge cleanup: use collection interfaces (List, Set, Map) rather than

implementations (ArrayList etc.) in references to objects
This commit is contained in:
elcnesh
2015-05-17 11:28:21 +00:00
parent 6274c5379a
commit b3f38edef3
105 changed files with 521 additions and 436 deletions

View File

@@ -223,7 +223,7 @@ public class BoosterGenerator {
} else if (operator.startsWith("fromSheet(") && invert) {
String sheetName = StringUtils.strip(operator.substring(9), "()\" ");
Iterable<PaperCard> src = StaticData.instance().getPrintSheets().get(sheetName).toFlatList();
ArrayList<String> cardNames = Lists.newArrayList();
List<String> cardNames = Lists.newArrayList();
for (PaperCard card : src) {
cardNames.add(card.getName());
}

View File

@@ -22,6 +22,7 @@ import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
import org.apache.commons.lang3.Range;
import org.apache.commons.lang3.tuple.ImmutablePair;
@@ -50,7 +51,7 @@ public enum DeckFormat {
Limited ( Range.between(40, Integer.MAX_VALUE), null, Integer.MAX_VALUE),
Commander ( Range.is(99), Range.between(0, 10), 1),
TinyLeaders ( Range.is(49), Range.between(0, 10), 1, new Predicate<CardRules>() {
private final HashSet<String> bannedCards = new HashSet<String>(Arrays.asList(
private final Set<String> bannedCards = new HashSet<String>(Arrays.asList(
"Ancestral Recall", "Balance", "Black Lotus", "Black Vise", "Channel", "Chaos Orb", "Contract From Below", "Counterbalance", "Darkpact", "Demonic Attorney", "Demonic Tutor", "Earthcraft", "Edric, Spymaster of Trest", "Falling Star",
"Fastbond", "Flash", "Goblin Recruiter", "Hermit Druid", "Imperial Seal", "Jeweled Bird", "Karakas", "Library of Alexandria", "Mana Crypt", "Mana Drain", "Mana Vault", "Metalworker", "Mind Twist", "Mishra's Workshop", "Mox Emerald",
"Mox Jet", "Mox Pearl", "Mox Ruby", "Mox Sapphire", "Necropotence", "Painter's Servant", "Shahrazad", "Skullclamp", "Sol Ring", "Strip Mine", "Survival of the Fittest", "Sword of Body and Mind", "Time Vault", "Time Walk", "Timetwister",

View File

@@ -1,6 +1,7 @@
package forge.deck.generation;
import java.util.HashMap;
import java.util.Map;
import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
@@ -8,7 +9,7 @@ import com.google.common.collect.Iterables;
import forge.item.PaperCard;
public class DeckGenPool implements IDeckGenPool {
private final HashMap<String, PaperCard> cards = new HashMap<String, PaperCard>();
private final Map<String, PaperCard> cards = new HashMap<String, PaperCard>();
public DeckGenPool() {
}

View File

@@ -1,41 +1,41 @@
package forge.util;
import java.util.List;
import java.util.Set;
import java.util.SortedSet;
import com.google.common.base.Supplier;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.TreeSet;
public final class CollectionSuppliers {
/**
* TODO: Write javadoc for this type.
*
*/
public abstract class CollectionSuppliers {
/**
* Private constructor to prevent instantiation.
*/
private CollectionSuppliers() {
}
public static <T> Supplier<ArrayList<T>> arrayLists() {
return new Supplier<ArrayList<T>>() {
@Override
public ArrayList<T> get() {
return new ArrayList<T>();
public static <T> Supplier<List<T>> arrayLists() {
return new Supplier<List<T>>() {
@Override public List<T> get() {
return Lists.newArrayList();
}
};
}
public static <T> Supplier<HashSet<T>> hashSets() {
return new Supplier<HashSet<T>>() {
@Override
public HashSet<T> get() {
return new HashSet<T>();
public static <T> Supplier<Set<T>> hashSets() {
return new Supplier<Set<T>>() {
@Override public Set<T> get() {
return Sets.newHashSet();
}
};
}
public static <T extends Comparable<T>> Supplier<TreeSet<T>> treeSets() {
return new Supplier<TreeSet<T>>() {
@Override
public TreeSet<T> get() {
return new TreeSet<T>();
public static <T extends Comparable<T>> Supplier<SortedSet<T>> treeSets() {
return new Supplier<SortedSet<T>>() {
@Override public SortedSet<T> get() {
return Sets.newTreeSet();
}
};
}

View File

@@ -234,7 +234,7 @@ public final class FileUtil {
* @return list of strings
*/
public static List<String> readAllLines(final Reader reader, final boolean mayTrim) {
final ArrayList<String> list = new ArrayList<String>();
final List<String> list = new ArrayList<String>();
try {
final BufferedReader in = new BufferedReader(reader);
String line;