mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
Huge cleanup: use collection interfaces (List, Set, Map) rather than
implementations (ArrayList etc.) in references to objects
This commit is contained in:
@@ -603,7 +603,7 @@ public class MultiLineLabelUI extends BasicLabelUI implements ComponentListener
|
||||
/**
|
||||
* Reused segments.
|
||||
*/
|
||||
private final ArrayList<Segment> segments = new ArrayList<Segment>(2);
|
||||
private final List<Segment> segments = new ArrayList<Segment>(2);
|
||||
|
||||
/**
|
||||
* Singleton instance.
|
||||
|
||||
@@ -94,7 +94,7 @@ public abstract class ItemManager<T extends InventoryItem> extends JPanel implem
|
||||
private final Class<T> genericType;
|
||||
private final CDetailPicture cDetailPicture;
|
||||
private ItemManagerConfig config;
|
||||
private final ArrayList<ListSelectionListener> selectionListeners = new ArrayList<ListSelectionListener>();
|
||||
private final List<ListSelectionListener> selectionListeners = new ArrayList<ListSelectionListener>();
|
||||
|
||||
private final SkinnedCheckBox chkEnableFilters = new SkinnedCheckBox();
|
||||
|
||||
|
||||
@@ -1,18 +1,20 @@
|
||||
package forge.itemmanager.filters;
|
||||
|
||||
import java.awt.Graphics;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import forge.UiCommand;
|
||||
import forge.item.InventoryItem;
|
||||
import forge.itemmanager.ItemManager;
|
||||
import forge.toolbox.FLabel;
|
||||
import forge.toolbox.FSkin;
|
||||
import forge.toolbox.LayoutHelper;
|
||||
import forge.toolbox.FSkin.SkinFont;
|
||||
import forge.toolbox.FSkin.SkinImage;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import forge.toolbox.LayoutHelper;
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this type.
|
||||
@@ -21,7 +23,7 @@ import java.util.ArrayList;
|
||||
@SuppressWarnings("serial")
|
||||
public abstract class ToggleButtonsFilter<T extends InventoryItem> extends ItemFilter<T> {
|
||||
protected boolean lockFiltering;
|
||||
private final ArrayList<FLabel> buttons = new ArrayList<FLabel>();
|
||||
private final List<FLabel> buttons = new ArrayList<FLabel>();
|
||||
|
||||
protected ToggleButtonsFilter(ItemManager<? super T> itemManager0) {
|
||||
super(itemManager0);
|
||||
|
||||
@@ -79,8 +79,8 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
|
||||
private Point hoverScrollPos;
|
||||
private ItemInfo hoveredItem;
|
||||
private ItemInfo focalItem;
|
||||
private final ArrayList<ItemInfo> orderedItems = new ArrayList<ItemInfo>();
|
||||
private final ArrayList<Group> groups = new ArrayList<Group>();
|
||||
private final List<ItemInfo> orderedItems = new ArrayList<ItemInfo>();
|
||||
private final List<Group> groups = new ArrayList<Group>();
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
private class ExpandCollapseButton extends FLabel {
|
||||
@@ -580,7 +580,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
|
||||
if (forRefresh && pileBy != null) { //refresh piles if needed
|
||||
//use TreeMap to build pile set so iterating below sorts on key
|
||||
ColumnDef groupPileBy = groupBy == null ? pileBy : groupBy.getGroupPileBy(i, pileBy);
|
||||
TreeMap<Comparable<?>, Pile> piles = new TreeMap<Comparable<?>, Pile>();
|
||||
Map<Comparable<?>, Pile> piles = new TreeMap<Comparable<?>, Pile>();
|
||||
for (ItemInfo itemInfo : group.items) {
|
||||
Comparable<?> key = groupPileBy.fnSort.apply(itemInfo);
|
||||
if (!piles.containsKey(key)) {
|
||||
|
||||
@@ -80,7 +80,7 @@ public class DeckHtmlSerializer {
|
||||
}
|
||||
}
|
||||
|
||||
final TreeMap<String, Integer> map = new TreeMap<String, Integer>();
|
||||
final Map<String, Integer> map = new TreeMap<String, Integer>();
|
||||
for (final Entry<PaperCard, Integer> entry : d.getMain()) {
|
||||
map.put(entry.getKey().getName(), entry.getValue());
|
||||
// System.out.println(entry.getValue() + " " +
|
||||
|
||||
@@ -242,7 +242,7 @@ public final class CMatchUI
|
||||
return FSkin.getAvatars().get(avatarIdx >= 0 ? avatarIdx : defaultIndex);
|
||||
}
|
||||
|
||||
private void initMatch(final FCollectionView<PlayerView> sortedPlayers, final Iterable<PlayerView> myPlayers) {
|
||||
private void initMatch(final FCollectionView<PlayerView> sortedPlayers, final Collection<PlayerView> myPlayers) {
|
||||
this.sortedPlayers = sortedPlayers;
|
||||
this.setLocalPlayers(myPlayers);
|
||||
allHands = sortedPlayers.size() == getLocalPlayerCount();
|
||||
|
||||
@@ -2,6 +2,7 @@ package forge.toolbox;
|
||||
|
||||
import java.awt.FlowLayout;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
|
||||
@@ -14,7 +15,7 @@ import forge.toolbox.FSkin.SkinnedLabel;
|
||||
@SuppressWarnings("serial")
|
||||
public class FComboBoxPanel<E> extends JPanel {
|
||||
|
||||
private static final ArrayList<FComboBoxPanel<?>> allPanels = new ArrayList<FComboBoxPanel<?>>();
|
||||
private static final List<FComboBoxPanel<?>> allPanels = new ArrayList<FComboBoxPanel<?>>();
|
||||
|
||||
public static void refreshAllSkins() {
|
||||
for (final FComboBoxPanel<?> panel : allPanels) {
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.awt.event.ActionListener;
|
||||
import java.awt.event.ItemListener;
|
||||
import java.awt.event.KeyListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.ComboBoxModel;
|
||||
import javax.swing.JComponent;
|
||||
@@ -22,7 +23,7 @@ import forge.toolbox.FSkin.SkinFont;
|
||||
*/
|
||||
public class FComboBoxWrapper<E> implements IComboBox<E> {
|
||||
|
||||
private static final ArrayList<FComboBoxWrapper<?>> allWrappers = new ArrayList<FComboBoxWrapper<?>>();
|
||||
private static final List<FComboBoxWrapper<?>> allWrappers = new ArrayList<FComboBoxWrapper<?>>();
|
||||
|
||||
public static void refreshAllSkins() {
|
||||
for (final FComboBoxWrapper<?> wrapper : allWrappers) {
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.awt.event.ActionListener;
|
||||
import java.text.DateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.Timer;
|
||||
|
||||
@@ -18,7 +19,7 @@ import forge.toolbox.FSkin.SkinnedLabel;
|
||||
public class FDigitalClock extends SkinnedLabel {
|
||||
private static final Calendar now = Calendar.getInstance();
|
||||
private static final DateFormat timeFormatter = DateFormat.getTimeInstance(DateFormat.SHORT);
|
||||
private static final ArrayList<FDigitalClock> clocks = new ArrayList<FDigitalClock>();
|
||||
private static final List<FDigitalClock> clocks = new ArrayList<FDigitalClock>();
|
||||
private static Timer timer;
|
||||
private static String currentTimeDisplay;
|
||||
|
||||
|
||||
@@ -1100,7 +1100,7 @@ public class FSkin {
|
||||
|
||||
if (allSkins == null) { //initialize
|
||||
allSkins = new ArrayList<String>();
|
||||
final ArrayList<String> skinDirectoryNames = getSkinDirectoryNames();
|
||||
final List<String> skinDirectoryNames = getSkinDirectoryNames();
|
||||
for (int i = 0; i < skinDirectoryNames.size(); i++) {
|
||||
allSkins.add(WordUtils.capitalize(skinDirectoryNames.get(i).replace('_', ' ')));
|
||||
}
|
||||
@@ -1337,8 +1337,8 @@ public class FSkin {
|
||||
*
|
||||
* @return the skins
|
||||
*/
|
||||
public static ArrayList<String> getSkinDirectoryNames() {
|
||||
final ArrayList<String> mySkins = new ArrayList<String>();
|
||||
public static List<String> getSkinDirectoryNames() {
|
||||
final List<String> mySkins = new ArrayList<String>();
|
||||
|
||||
final File dir = new File(ForgeConstants.SKINS_DIR);
|
||||
final String[] children = dir.list();
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package forge.ai.simulation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import forge.GuiBase;
|
||||
@@ -26,7 +27,6 @@ import forge.game.spellability.SpellAbility;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.item.IPaperCard;
|
||||
import forge.model.FModel;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class GameSimulatorTest extends TestCase {
|
||||
private static boolean initialized = false;
|
||||
@@ -319,7 +319,7 @@ public class GameSimulatorTest extends TestCase {
|
||||
game.getAction().checkStateEffects(true);
|
||||
|
||||
CardCollection cards = ComputerUtilAbility.getAvailableCards(game, p);
|
||||
ArrayList<SpellAbility> abilities = ComputerUtilAbility.getSpellAbilities(cards, p);
|
||||
List<SpellAbility> abilities = ComputerUtilAbility.getSpellAbilities(cards, p);
|
||||
SpellAbility minusTwo = findSAWithPrefix(abilities, "-2: Put a 2/2 black Vampire");
|
||||
assertNotNull(minusTwo);
|
||||
minusTwo.setActivatingPlayer(p);
|
||||
|
||||
@@ -9,8 +9,8 @@ import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.ListMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import forge.LobbyPlayer;
|
||||
@@ -465,26 +465,26 @@ public class PlayerControllerForTests extends PlayerController {
|
||||
return (CardCollection)items.subList(0, Math.max(amount, items.size()));
|
||||
}
|
||||
|
||||
private <T> T chooseItem(Iterable<T> items) {
|
||||
if (items == null) {
|
||||
return null;
|
||||
}
|
||||
return Iterables.getFirst(items, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpellAbility getAbilityToPlay(Card hostCard, List<SpellAbility> abilities, ITriggerEvent triggerEvent) {
|
||||
// Isn't this a method invocation loop? --elcnesh
|
||||
return getAbilityToPlay(hostCard, abilities);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String chooseSomeType(String kindOfType, SpellAbility sa, List<String> validTypes, List<String> invalidTypes, boolean isOptional) {
|
||||
return chooseItem(validTypes);
|
||||
}
|
||||
private <T> T chooseItem(Iterable<T> items) {
|
||||
if (items == null) {
|
||||
return null;
|
||||
}
|
||||
return Iterables.getFirst(items, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object vote(SpellAbility sa, String prompt, List<Object> options, ArrayListMultimap<Object, Player> votes) {
|
||||
public SpellAbility getAbilityToPlay(Card hostCard, List<SpellAbility> abilities, ITriggerEvent triggerEvent) {
|
||||
// Isn't this a method invocation loop? --elcnesh
|
||||
return getAbilityToPlay(hostCard, abilities);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String chooseSomeType(String kindOfType, SpellAbility sa, List<String> validTypes, List<String> invalidTypes, boolean isOptional) {
|
||||
return chooseItem(validTypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object vote(SpellAbility sa, String prompt, List<Object> options, ListMultimap<Object, Player> votes) {
|
||||
return chooseItem(options);
|
||||
}
|
||||
|
||||
@@ -509,9 +509,7 @@ public class PlayerControllerForTests extends PlayerController {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReplacementEffect chooseSingleReplacementEffect(String prompt,
|
||||
List<ReplacementEffect> possibleReplacers,
|
||||
HashMap<String, Object> runParams) {
|
||||
public ReplacementEffect chooseSingleReplacementEffect(String prompt, List<ReplacementEffect> possibleReplacers, Map<String, Object> runParams) {
|
||||
// TODO Auto-generated method stub
|
||||
return Iterables.getFirst(possibleReplacers, null);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user