Guava migration - Fix lingering build errors

This commit is contained in:
Jetz
2024-09-02 19:51:21 -04:00
parent 055dff71ce
commit 16c0fa1095
10 changed files with 15 additions and 18 deletions

View File

@@ -46,7 +46,7 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
private final String exlcudedCardSet = "DS0";
// need this to obtain cardReference by name+set+artindex
private final ListMultimap<String, PaperCard> allCardsByName = Multimaps.newListMultimap(new TreeMap<>(String.CASE_INSENSITIVE_ORDER), CollectionSuppliers.arrayLists());
private final ListMultimap<String, PaperCard> allCardsByName = Multimaps.newListMultimap(new TreeMap<>(String.CASE_INSENSITIVE_ORDER), Lists::newArrayList);
private final Map<String, PaperCard> uniqueCardsByName = Maps.newTreeMap(String.CASE_INSENSITIVE_ORDER);
private final Map<String, CardRules> rulesByName;
private final Map<String, ICardFace> facesByName = Maps.newTreeMap(String.CASE_INSENSITIVE_ORDER);

View File

@@ -403,7 +403,7 @@ public final class CardEdition implements Comparable<CardEdition> {
public List<CardInSet> getCardInSet(String cardName){
if (cardsInSetLookupMap == null) {
// initialise
cardsInSetLookupMap = Multimaps.newListMultimap(new TreeMap<>(String.CASE_INSENSITIVE_ORDER), CollectionSuppliers.arrayLists());
cardsInSetLookupMap = Multimaps.newListMultimap(new TreeMap<>(String.CASE_INSENSITIVE_ORDER), Lists::newArrayList);
List<CardInSet> cardsInSet = this.getAllCardsInSet();
for (CardInSet cis : cardsInSet){
String key = cis.name;

View File

@@ -25,7 +25,6 @@ import forge.card.CardDb;
import forge.card.CardEdition;
import forge.item.IPaperCard;
import forge.item.PaperCard;
import forge.util.CollectionSuppliers;
import forge.util.ItemPool;
import forge.util.ItemPoolSorter;
import forge.util.MyRandom;
@@ -205,7 +204,7 @@ public class CardPool extends ItemPool<PaperCard> {
*/
public ListMultimap<Integer, CardEdition> getCardEditionsGroupedByNumberOfCards(boolean includeBasicLands){
Map<CardEdition, Integer> editionsFrequencyMap = this.getCardEditionStatistics(includeBasicLands);
ListMultimap<Integer, CardEdition> reverseMap = Multimaps.newListMultimap(new HashMap<>(), CollectionSuppliers.arrayLists());
ListMultimap<Integer, CardEdition> reverseMap = Multimaps.newListMultimap(new HashMap<>(), Lists::newArrayList);
for (Map.Entry<CardEdition, Integer> entry : editionsFrequencyMap.entrySet())
reverseMap.put(entry.getValue(), entry.getKey());
return reverseMap;

View File

@@ -79,9 +79,8 @@ public class Iterables {
return iterable.stream().filter(predicate).findFirst().orElse(defaultValue);
}
public static <T> boolean removeIf(Iterable<T> iterable, Predicate<T> test) {
//TODO: Convert parameter type
return ((Collection<T>) iterable).removeIf(test);
public static <T> boolean removeIf(Collection<T> iterable, Predicate<? super T> test) {
return iterable.removeIf(test);
}
public static boolean removeAll(Collection<?> removeFrom, Collection<?> toRemove) {
@@ -105,14 +104,14 @@ public class Iterables {
}
public static <T> T getFirst(List<? extends T> iterable, T defaultValue) {
return iterable.isEmpty() ? defaultValue : iterable.getFirst();
return iterable.isEmpty() ? defaultValue : iterable.get(0);
}
public static <T> T getLast(List<T> iterable) {
return iterable.getLast();
return iterable.get(iterable.size() - 1);
}
public static <T> T getLast(List<? extends T> iterable, T defaultValue) {
return iterable.isEmpty() ? defaultValue : iterable.getLast();
return iterable.isEmpty() ? defaultValue : iterable.get(iterable.size() - 1);
}
public static boolean isEmpty(Collection<?> iterable) {
return iterable.isEmpty();

View File

@@ -16,7 +16,6 @@ import forge.model.FModel;
import forge.screens.home.quest.DialogChooseFormats;
import forge.screens.home.quest.DialogChooseSets;
import forge.screens.match.controllers.CDetailPicture;
import forge.util.CollectionSuppliers;
import forge.util.Iterables;
import forge.util.Localizer;
@@ -56,7 +55,7 @@ public class CardManager extends ItemManager<PaperCard> {
@Override
protected Iterable<Entry<PaperCard, Integer>> getUnique(Iterable<Entry<PaperCard, Integer>> items) {
ListMultimap<String, Entry<PaperCard, Integer>> entriesByName = Multimaps.newListMultimap(
new TreeMap<>(String.CASE_INSENSITIVE_ORDER), CollectionSuppliers.arrayLists());
new TreeMap<>(String.CASE_INSENSITIVE_ORDER), Lists::newArrayList);
for (Entry<PaperCard, Integer> item : items) {
final String cardName = item.getKey().getName();
entriesByName.put(cardName, item);
@@ -67,7 +66,7 @@ public class CardManager extends ItemManager<PaperCard> {
for (String cardName : entriesByName.keySet()) {
List<Entry<PaperCard, Integer>> entries = entriesByName.get(cardName);
ListMultimap<CardEdition, Entry<PaperCard, Integer>> entriesByEdition = Multimaps.newListMultimap(new HashMap<>(), CollectionSuppliers.arrayLists());
ListMultimap<CardEdition, Entry<PaperCard, Integer>> entriesByEdition = Multimaps.newListMultimap(new HashMap<>(), Lists::newArrayList);
for (Entry<PaperCard, Integer> entry : entries) {
CardEdition ed = StaticData.instance().getCardEdition(entry.getKey().getEdition());
if (ed != null)

View File

@@ -59,7 +59,7 @@ public abstract class StatTypeFilter<T extends InventoryItem> extends ToggleButt
protected <U extends InventoryItem> boolean showUnsupportedItem(U item) {
FLabel btnPackOrDeck = buttonMap.get(StatTypes.PACK_OR_DECK); //support special pack/deck case
if (btnPackOrDeck != null && btnPackOrDeck.isSelected()) {
return ItemPredicate.Presets.IS_PACK_OR_DECK.apply(item);
return ItemPredicate.Presets.IS_PACK_OR_DECK.test(item);
}
return false;
}

View File

@@ -25,7 +25,7 @@ import forge.item.PaperCard;
public class LegacyCardDb {
public CardEdition.Collection editions;
public ListMultimap<String, PaperCard> allCardsByName = Multimaps
.newListMultimap(new TreeMap<>(String.CASE_INSENSITIVE_ORDER), CollectionSuppliers.arrayLists());
.newListMultimap(new TreeMap<>(String.CASE_INSENSITIVE_ORDER), Lists::newArrayList);
public enum LegacySetPreference {
Latest(false), LatestCoreExp(true), Earliest(false), EarliestCoreExp(true), Random(false);

View File

@@ -37,7 +37,7 @@ public abstract class StatTypeFilter<T extends InventoryItem> extends ToggleButt
protected <U extends InventoryItem> boolean showUnsupportedItem(U item) {
FLabel btnPackOrDeck = buttonMap.get(StatTypes.PACK_OR_DECK); //support special pack/deck case
if (btnPackOrDeck != null && btnPackOrDeck.isSelected()) {
return ItemPredicate.Presets.IS_PACK_OR_DECK.apply(item);
return ItemPredicate.Presets.IS_PACK_OR_DECK.test(item);
}
return false;
}

View File

@@ -254,7 +254,7 @@ public class QuestWorld implements Comparable<QuestWorld>{
if (format == null) {
format = FModel.getQuest().getMainFormat();
}
if (format == null || format.getFilterRules().apply(card)) {
if (format == null || format.getFilterRules().test(card)) {
result.add(qw);
}
}

View File

@@ -896,7 +896,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
@Override
protected boolean onCardSelected(final Card c, final List<Card> otherCardsToSelect, final ITriggerEvent triggerEvent) {
final Card firstCard = Iterables.getFirst(this.selected, null);
if (firstCard != null && !CardPredicates.sharesColorWith(firstCard).apply(c)) {
if (firstCard != null && !CardPredicates.sharesColorWith(firstCard).test(c)) {
return false;
}
return super.onCardSelected(c, otherCardsToSelect, triggerEvent);