Guava migration - Rename StreamUtils -> StreamUtil for consistency

This commit is contained in:
Jetz
2024-09-25 09:01:46 -04:00
parent 1395baa2ff
commit f636910ebb
9 changed files with 18 additions and 18 deletions

View File

@@ -2452,7 +2452,7 @@ public class ComputerUtil {
if (minDiff > 0) {
List<Card> choices = validCards.stream()
.filter(((Predicate<Card>) goodChoices::contains).negate())
.collect(StreamUtils.random(minDiff));
.collect(StreamUtil.random(minDiff));
goodChoices.addAll(choices);
return goodChoices;
}

View File

@@ -238,7 +238,7 @@ public abstract class DeckGeneratorBase {
for (int i = 0; i < 3 && actualSize > targetSize; i++) {
List<PaperCard> toRemove = tDeck.toFlatList().stream()
.filter(PaperCardPredicates.NOT_BASIC_LAND)
.collect(StreamUtils.random(actualSize - targetSize));
.collect(StreamUtil.random(actualSize - targetSize));
tDeck.removeAllFlat(toRemove);
for (PaperCard c : toRemove) {

View File

@@ -20,7 +20,7 @@ package forge.item;
import forge.StaticData;
import forge.item.generation.BoosterGenerator;
import forge.util.StreamUtils;
import forge.util.StreamUtil;
import java.util.ArrayList;
import java.util.List;
@@ -112,6 +112,6 @@ public abstract class SealedProduct implements InventoryItemFromSet {
return StaticData.instance().getCommonCards().streamAllCards()
.filter(PaperCardPredicates.printedInSet(setCode))
.filter(PaperCardPredicates.IS_BASIC_LAND)
.collect(StreamUtils.random(count));
.collect(StreamUtil.random(count));
}
}

View File

@@ -5,9 +5,9 @@ import java.util.function.*;
import java.util.stream.Collector;
import java.util.stream.Stream;
public class StreamUtils {
public class StreamUtil {
private StreamUtils(){}
private StreamUtil(){}
/**
* Reduces a stream to a random element of the stream. Used with {@link Stream#collect}.

View File

@@ -132,7 +132,7 @@ public class ChooseCardNameEffect extends SpellAbilityEffect {
}
if (randomChoice) {
chosen = StaticData.instance().getCommonCards().streamAllFaces()
.filter(cpp).collect(StreamUtils.random()).get()
.filter(cpp).collect(StreamUtil.random()).get()
.getName();
} else {
chosen = p.getController().chooseCardName(sa, cpp, valid, message);

View File

@@ -130,7 +130,7 @@ public class PlayEffect extends SpellAbilityEffect {
final CardCollection choice = new CardCollection();
final String num = sa.getParamOrDefault("RandomNum", "1");
int nCopied = AbilityUtils.calculateAmount(source, num, sa);
for (PaperCard cp : cards.collect(StreamUtils.random(nCopied))) {
for (PaperCard cp : cards.collect(StreamUtil.random(nCopied))) {
final Card possibleCard = Card.fromPaperCard(cp, sa.getActivatingPlayer());
if (sa.getActivatingPlayer().isAI() && possibleCard.getRules() != null && possibleCard.getRules().getAiHints().getRemAIDecks())
continue;

View File

@@ -21,7 +21,7 @@ import forge.model.FModel;
import forge.screens.deckeditor.CDeckEditorUI;
import forge.screens.deckeditor.SEditorIO;
import forge.screens.deckeditor.views.VDeckgen;
import forge.util.StreamUtils;
import forge.util.StreamUtil;
import java.util.List;
@@ -70,7 +70,7 @@ public enum CDeckgen implements ICDoc {
List<PaperCard> randomCards = FModel.getMagicDb().getCommonCards().streamUniqueCards()
.filter(PaperCardPredicates.NOT_BASIC_LAND)
.collect(StreamUtils.random(15 * 5));
.collect(StreamUtil.random(15 * 5));
randomDeck.getMain().addAllFlat(randomCards);
for(final String landName : MagicColor.Constant.BASIC_LANDS) {

View File

@@ -465,7 +465,7 @@ public class DeckgenUtil {
if (!selection.isEmpty())
deck = geneticAI.stream()
.filter(deckProxy -> deckProxy.getColorIdentity().sharesColorWith(ColorSet.fromNames(colors.toCharArray())))
.collect(StreamUtils.random()).get().getDeck();
.collect(StreamUtil.random()).get().getDeck();
else
deck = Aggregates.random(geneticAI).getDeck();
@@ -474,7 +474,7 @@ public class DeckgenUtil {
if (!selection.isEmpty() && selection.size() < 4)
predicate = predicate.and(deckProxy -> deckProxy.getColorIdentity().hasAllColors(ColorSet.fromNames(colors.toCharArray()).getColor()));
List<DeckProxy> source = isTheme ? advThemes : advPrecons;
deck = source.stream().filter(predicate).collect(StreamUtils.random()).get().getDeck();
deck = source.stream().filter(predicate).collect(StreamUtil.random()).get().getDeck();
}
} catch (Exception e) {
e.printStackTrace();
@@ -659,7 +659,7 @@ public class DeckgenUtil {
.filter(format.isLegalCardPredicate())
.filter(format.isLegalCommanderPredicate())
.filter(PaperCardPredicates.fromRules(canPlay))
.collect(StreamUtils.random()).get();
.collect(StreamUtil.random()).get();
return generateRandomCommanderDeck(commander, format, forAi, false);
}

View File

@@ -223,7 +223,7 @@ public final class QuestUtilCards {
Stream<PaperCard> pool = getQuestCardPool();
final PaperCard card = pool
.filter(applyFormatFilter(PaperCardPredicates.IS_RARE_OR_MYTHIC))
.collect(StreamUtils.random()).get();
.collect(StreamUtil.random()).get();
addSingleCard(card, 1);
return card;
@@ -239,7 +239,7 @@ public final class QuestUtilCards {
*/
public List<PaperCard> addRandomCards(final int n, Predicate<PaperCard> predicate) {
Stream<PaperCard> pool = getQuestCardPool();
final List<PaperCard> newCards = pool.filter(predicate).collect(StreamUtils.random(n));
final List<PaperCard> newCards = pool.filter(predicate).collect(StreamUtil.random(n));
addAllCards(newCards);
return newCards;
@@ -560,7 +560,7 @@ public final class QuestUtilCards {
.filter(CardEdition.Predicates.HAS_TOURNAMENT_PACK)
.filter(isLegalInQuestFormat(questController.getFormat()))
.map(TournamentPack::fromSet)
.collect(StreamUtils.random(count));
.collect(StreamUtil.random(count));
questAssets.getShopList().addAllOfTypeFlat(packs);
}
@@ -575,7 +575,7 @@ public final class QuestUtilCards {
.filter(CardEdition.Predicates.HAS_FAT_PACK)
.filter(isLegalInQuestFormat(questController.getFormat()))
.map(FatPack::fromSet)
.collect(StreamUtils.random(count));
.collect(StreamUtil.random(count));
questAssets.getShopList().addAllOfTypeFlat(packs);
}
@@ -625,7 +625,7 @@ public final class QuestUtilCards {
}
final List<PreconDeck> decks = QuestController.getPrecons().stream()
.filter(formatFilter)
.collect(StreamUtils.random(count));
.collect(StreamUtil.random(count));
questAssets.getShopList().addAllOfTypeFlat(decks);
}