mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
Guava migration - Remove CollectionSuppliers
This commit is contained in:
@@ -1,30 +0,0 @@
|
|||||||
package forge.util;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.SortedSet;
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.google.common.collect.Sets;
|
|
||||||
|
|
||||||
public final class CollectionSuppliers {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Private constructor to prevent instantiation.
|
|
||||||
*/
|
|
||||||
private CollectionSuppliers() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> Supplier<List<T>> arrayLists() {
|
|
||||||
return Lists::newArrayList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> Supplier<Set<T>> hashSets() {
|
|
||||||
return Sets::newHashSet;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T extends Comparable<T>> Supplier<SortedSet<T>> treeSets() {
|
|
||||||
return Sets::newTreeSet;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -40,7 +40,6 @@ import forge.game.trigger.Trigger;
|
|||||||
import forge.game.trigger.TriggerType;
|
import forge.game.trigger.TriggerType;
|
||||||
import forge.game.zone.Zone;
|
import forge.game.zone.Zone;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
import forge.util.CollectionSuppliers;
|
|
||||||
import forge.util.TextUtil;
|
import forge.util.TextUtil;
|
||||||
import forge.util.maps.HashMapOfLists;
|
import forge.util.maps.HashMapOfLists;
|
||||||
import forge.util.maps.MapOfLists;
|
import forge.util.maps.MapOfLists;
|
||||||
@@ -716,7 +715,7 @@ public class PhaseHandler implements java.io.Serializable {
|
|||||||
// map: defender => (many) attacker => (many) blocker
|
// map: defender => (many) attacker => (many) blocker
|
||||||
Map<GameEntity, MapOfLists<Card, Card>> blockers = Maps.newHashMap();
|
Map<GameEntity, MapOfLists<Card, Card>> blockers = Maps.newHashMap();
|
||||||
for (GameEntity ge : combat.getDefendersControlledBy(p)) {
|
for (GameEntity ge : combat.getDefendersControlledBy(p)) {
|
||||||
MapOfLists<Card, Card> protectThisDefender = new HashMapOfLists<>(CollectionSuppliers.arrayLists());
|
MapOfLists<Card, Card> protectThisDefender = new HashMapOfLists<>(ArrayList::new);
|
||||||
for (Card att : combat.getAttackersOf(ge)) {
|
for (Card att : combat.getAttackersOf(ge)) {
|
||||||
protectThisDefender.addAll(att, combat.getBlockers(att));
|
protectThisDefender.addAll(att, combat.getBlockers(att));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,11 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package forge.game.zone;
|
package forge.game.zone;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.*;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
@@ -34,7 +30,6 @@ import forge.game.card.*;
|
|||||||
import forge.game.event.EventValueChangeType;
|
import forge.game.event.EventValueChangeType;
|
||||||
import forge.game.event.GameEventZone;
|
import forge.game.event.GameEventZone;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.util.CollectionSuppliers;
|
|
||||||
import forge.util.MyRandom;
|
import forge.util.MyRandom;
|
||||||
import forge.util.maps.EnumMapOfLists;
|
import forge.util.maps.EnumMapOfLists;
|
||||||
import forge.util.maps.MapOfLists;
|
import forge.util.maps.MapOfLists;
|
||||||
@@ -54,8 +49,8 @@ public class Zone implements java.io.Serializable, Iterable<Card> {
|
|||||||
protected final ZoneType zoneType;
|
protected final ZoneType zoneType;
|
||||||
protected final Game game;
|
protected final Game game;
|
||||||
|
|
||||||
protected final transient MapOfLists<ZoneType, Card> cardsAddedThisTurn = new EnumMapOfLists<>(ZoneType.class, CollectionSuppliers.arrayLists());
|
protected final transient MapOfLists<ZoneType, Card> cardsAddedThisTurn = new EnumMapOfLists<>(ZoneType.class, ArrayList::new);
|
||||||
protected final transient MapOfLists<ZoneType, Card> cardsAddedLastTurn = new EnumMapOfLists<>(ZoneType.class, CollectionSuppliers.arrayLists());
|
protected final transient MapOfLists<ZoneType, Card> cardsAddedLastTurn = new EnumMapOfLists<>(ZoneType.class, ArrayList::new);
|
||||||
|
|
||||||
public Zone(final ZoneType zone0, Game game0) {
|
public Zone(final ZoneType zone0, Game game0) {
|
||||||
zoneType = zone0;
|
zoneType = zone0;
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import forge.localinstance.properties.ForgeConstants;
|
|||||||
import forge.toolbox.FAbsolutePositioner;
|
import forge.toolbox.FAbsolutePositioner;
|
||||||
import forge.toolbox.SaveOpenDialog;
|
import forge.toolbox.SaveOpenDialog;
|
||||||
import forge.toolbox.SaveOpenDialog.Filetypes;
|
import forge.toolbox.SaveOpenDialog.Filetypes;
|
||||||
import forge.util.CollectionSuppliers;
|
|
||||||
import forge.util.ThreadUtil;
|
import forge.util.ThreadUtil;
|
||||||
import forge.util.maps.HashMapOfLists;
|
import forge.util.maps.HashMapOfLists;
|
||||||
import forge.util.maps.MapOfLists;
|
import forge.util.maps.MapOfLists;
|
||||||
@@ -23,6 +22,7 @@ import javax.xml.stream.events.StartElement;
|
|||||||
import javax.xml.stream.events.XMLEvent;
|
import javax.xml.stream.events.XMLEvent;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -514,7 +514,7 @@ public final class SLayoutIO {
|
|||||||
EDocID selectedId = null;
|
EDocID selectedId = null;
|
||||||
double x0 = 0, y0 = 0, w0 = 0, h0 = 0;
|
double x0 = 0, y0 = 0, w0 = 0, h0 = 0;
|
||||||
|
|
||||||
MapOfLists<LayoutInfo, EDocID> model = new HashMapOfLists<>(CollectionSuppliers.arrayLists());
|
MapOfLists<LayoutInfo, EDocID> model = new HashMapOfLists<>(ArrayList::new);
|
||||||
|
|
||||||
LayoutInfo currentKey = null;
|
LayoutInfo currentKey = null;
|
||||||
while (null != reader && reader.hasNext()) {
|
while (null != reader && reader.hasNext()) {
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
package forge.gamemodes.match;
|
package forge.gamemodes.match;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import forge.ai.AiProfileUtil;
|
import forge.ai.AiProfileUtil;
|
||||||
import forge.gui.control.PlaybackSpeed;
|
import forge.gui.control.PlaybackSpeed;
|
||||||
@@ -53,7 +49,6 @@ import forge.player.PlayerControllerHuman;
|
|||||||
import forge.sound.MusicPlaylist;
|
import forge.sound.MusicPlaylist;
|
||||||
import forge.sound.SoundSystem;
|
import forge.sound.SoundSystem;
|
||||||
import forge.trackable.TrackableCollection;
|
import forge.trackable.TrackableCollection;
|
||||||
import forge.util.CollectionSuppliers;
|
|
||||||
import forge.util.TextUtil;
|
import forge.util.TextUtil;
|
||||||
import forge.util.collect.FCollectionView;
|
import forge.util.collect.FCollectionView;
|
||||||
import forge.util.maps.HashMapOfLists;
|
import forge.util.maps.HashMapOfLists;
|
||||||
@@ -189,7 +184,7 @@ public class HostedMatch {
|
|||||||
final GameView gameView = getGameView();
|
final GameView gameView = getGameView();
|
||||||
|
|
||||||
humanCount = 0;
|
humanCount = 0;
|
||||||
final MapOfLists<IGuiGame, PlayerView> playersPerGui = new HashMapOfLists<>(CollectionSuppliers.arrayLists());
|
final MapOfLists<IGuiGame, PlayerView> playersPerGui = new HashMapOfLists<>(ArrayList::new);
|
||||||
for (int iPlayer = 0; iPlayer < players.size(); iPlayer++) {
|
for (int iPlayer = 0; iPlayer < players.size(); iPlayer++) {
|
||||||
final RegisteredPlayer rp = match.getPlayers().get(iPlayer);
|
final RegisteredPlayer rp = match.getPlayers().get(iPlayer);
|
||||||
final Player p = players.get(iPlayer);
|
final Player p = players.get(iPlayer);
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import forge.gamemodes.quest.data.QuestPreferences.DifficultyPrefs;
|
|||||||
import forge.gamemodes.quest.data.QuestPreferences.QPref;
|
import forge.gamemodes.quest.data.QuestPreferences.QPref;
|
||||||
import forge.gamemodes.quest.io.MainWorldDuelReader;
|
import forge.gamemodes.quest.io.MainWorldDuelReader;
|
||||||
import forge.model.FModel;
|
import forge.model.FModel;
|
||||||
import forge.util.CollectionSuppliers;
|
|
||||||
import forge.util.MyRandom;
|
import forge.util.MyRandom;
|
||||||
import forge.util.maps.EnumMapOfLists;
|
import forge.util.maps.EnumMapOfLists;
|
||||||
import forge.util.maps.MapOfLists;
|
import forge.util.maps.MapOfLists;
|
||||||
@@ -20,7 +19,7 @@ import forge.util.storage.StorageBase;
|
|||||||
|
|
||||||
public class MainWorldEventDuelManager implements QuestEventDuelManagerInterface {
|
public class MainWorldEventDuelManager implements QuestEventDuelManagerInterface {
|
||||||
|
|
||||||
protected final MapOfLists<QuestEventDifficulty, QuestEventDuel> sortedDuels = new EnumMapOfLists<>(QuestEventDifficulty.class, CollectionSuppliers.arrayLists());
|
protected final MapOfLists<QuestEventDifficulty, QuestEventDuel> sortedDuels = new EnumMapOfLists<>(QuestEventDifficulty.class, ArrayList::new);
|
||||||
protected final IStorage<QuestEventDuel> allDuels;
|
protected final IStorage<QuestEventDuel> allDuels;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ import forge.gamemodes.quest.data.QuestPreferences.DifficultyPrefs;
|
|||||||
import forge.gamemodes.quest.data.QuestPreferences.QPref;
|
import forge.gamemodes.quest.data.QuestPreferences.QPref;
|
||||||
import forge.gamemodes.quest.io.QuestDuelReader;
|
import forge.gamemodes.quest.io.QuestDuelReader;
|
||||||
import forge.model.FModel;
|
import forge.model.FModel;
|
||||||
import forge.util.CollectionSuppliers;
|
|
||||||
import forge.util.MyRandom;
|
import forge.util.MyRandom;
|
||||||
import forge.util.maps.EnumMapOfLists;
|
import forge.util.maps.EnumMapOfLists;
|
||||||
import forge.util.maps.MapOfLists;
|
import forge.util.maps.MapOfLists;
|
||||||
@@ -43,7 +42,7 @@ import forge.util.storage.StorageBase;
|
|||||||
*/
|
*/
|
||||||
public class QuestEventDuelManager implements QuestEventDuelManagerInterface {
|
public class QuestEventDuelManager implements QuestEventDuelManagerInterface {
|
||||||
|
|
||||||
private final MapOfLists<QuestEventDifficulty, QuestEventDuel> sortedDuels = new EnumMapOfLists<>(QuestEventDifficulty.class, CollectionSuppliers.arrayLists());
|
private final MapOfLists<QuestEventDifficulty, QuestEventDuel> sortedDuels = new EnumMapOfLists<>(QuestEventDifficulty.class, ArrayList::new);
|
||||||
private final IStorage<QuestEventDuel> allDuels;
|
private final IStorage<QuestEventDuel> allDuels;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ import forge.gamemodes.quest.data.QuestPreferences;
|
|||||||
import forge.gamemodes.quest.data.QuestPreferences.DifficultyPrefs;
|
import forge.gamemodes.quest.data.QuestPreferences.DifficultyPrefs;
|
||||||
import forge.gamemodes.quest.data.QuestPreferences.QPref;
|
import forge.gamemodes.quest.data.QuestPreferences.QPref;
|
||||||
import forge.model.FModel;
|
import forge.model.FModel;
|
||||||
import forge.util.CollectionSuppliers;
|
|
||||||
import forge.util.MyRandom;
|
import forge.util.MyRandom;
|
||||||
import forge.util.maps.EnumMapOfLists;
|
import forge.util.maps.EnumMapOfLists;
|
||||||
import forge.util.maps.MapOfLists;
|
import forge.util.maps.MapOfLists;
|
||||||
@@ -43,7 +42,7 @@ import forge.util.maps.MapOfLists;
|
|||||||
public class QuestEventLDADuelManager implements QuestEventDuelManagerInterface {
|
public class QuestEventLDADuelManager implements QuestEventDuelManagerInterface {
|
||||||
|
|
||||||
private List<Archetype> archetypes;
|
private List<Archetype> archetypes;
|
||||||
private final MapOfLists<QuestEventDifficulty, QuestEventDuel> sortedDuels = new EnumMapOfLists<>(QuestEventDifficulty.class, CollectionSuppliers.arrayLists());
|
private final MapOfLists<QuestEventDifficulty, QuestEventDuel> sortedDuels = new EnumMapOfLists<>(QuestEventDifficulty.class, ArrayList::new);
|
||||||
private GameFormat baseFormat;
|
private GameFormat baseFormat;
|
||||||
|
|
||||||
public QuestEventLDADuelManager(GameFormat baseFormat){
|
public QuestEventLDADuelManager(GameFormat baseFormat){
|
||||||
|
|||||||
Reference in New Issue
Block a user