Cleanup - .equals("") -> .isEmpty()

This commit is contained in:
Jetz
2024-08-10 12:28:18 -04:00
parent 9bbe4805a3
commit 0ee46ff6ef
35 changed files with 51 additions and 51 deletions

View File

@@ -2591,7 +2591,7 @@ public class ComputerUtil {
chosen = b;
}
}
if (chosen.equals("")) {
if (chosen.isEmpty()) {
for (String b : basics) {
if (Iterables.any(possibleCards, CardPredicates.isType(b))) {
chosen = b;

View File

@@ -421,7 +421,7 @@ public class ComputerUtilCombat {
final List<Card> blockers = combat.getBlockers(attacker);
if (blockers.isEmpty()) {
if (!attacker.getSVar("MustBeBlocked").equals("")) {
if (!attacker.getSVar("MustBeBlocked").isEmpty()) {
boolean cond = false;
String condVal = attacker.getSVar("MustBeBlocked");
boolean isAttackingPlayer = combat.getDefenderByAttacker(attacker) instanceof Player;
@@ -490,7 +490,7 @@ public class ComputerUtilCombat {
final List<Card> blockers = combat.getBlockers(attacker);
if (blockers.isEmpty()) {
if (!attacker.getSVar("MustBeBlocked").equals("")) {
if (!attacker.getSVar("MustBeBlocked").isEmpty()) {
return true;
}
}

View File

@@ -1040,7 +1040,7 @@ public class ComputerUtilMana {
// If it's a low priority spell (it's explicitly marked so elsewhere in the AI with a SVar), always
// obey mana reservations for Main 2; otherwise, obey mana reservations depending on the "chance to reserve"
// AI profile variable.
if (sa.getSVar("LowPriorityAI").equals("")) {
if (sa.getSVar("LowPriorityAI").isEmpty()) {
if (chanceToReserve == 0 || MyRandom.getRandom().nextInt(100) >= chanceToReserve) {
return false;
}

View File

@@ -168,7 +168,7 @@ public class ChooseCardAi extends SpellAbilityAi {
logic = logic.replace("NotSelf", "");
}
Card choice = null;
if (logic.equals("")) {
if (logic.isEmpty()) {
// Base Logic is choose "best"
choice = ComputerUtilCard.getBestAI(options);
} else if ("WorstCard".equals(logic)) {

View File

@@ -337,7 +337,7 @@ public final class ImageKeys {
File f = new File(lookupDirectory);
if (f.exists() && f.isDirectory()) {
for (String ext : FILE_EXTENSIONS) {
if (ext.equals(""))
if (ext.isEmpty())
continue;
File placeholder;
String fb1 = fullborderFile.replace(setKey+"/","")+ext;
@@ -371,7 +371,7 @@ public final class ImageKeys {
private static File findFile(String dir, String filename) {
if (dir.equals(CACHE_CARD_PICS_DIR)) {
for (String ext : FILE_EXTENSIONS) {
if (ext.equals(""))
if (ext.isEmpty())
continue;
File f = new File(dir, filename + ext);

View File

@@ -550,7 +550,7 @@ public class Deck extends DeckBase implements Iterable<Entry<DeckSection, CardPo
}
public void setAiHints(String aiHintsInfo) {
if (aiHintsInfo == null || aiHintsInfo.trim().equals("")) {
if (aiHintsInfo == null || aiHintsInfo.trim().isEmpty()) {
return;
}
String[] hints = aiHintsInfo.split("\\|");

View File

@@ -75,7 +75,7 @@ public abstract class DeckBase implements Serializable, Comparable<DeckBase>, In
public void setName(String deckName) { this.name = deckName; }
public boolean hasName() {
return !(this.name.equals(""));
return !(this.name.isEmpty());
}
public String getDirectory() {

View File

@@ -111,13 +111,13 @@ public class DeckRecognizer {
// WARNING MESSAGES
// ================
public static Token UnknownCard(final String cardName, final String setCode, final int count) {
String ttext = setCode == null || setCode.equals("") ? cardName :
String ttext = setCode == null || setCode.isEmpty() ? cardName :
String.format("%s [%s]", cardName, setCode);
return new Token(TokenType.UNKNOWN_CARD, count, ttext);
}
public static Token UnsupportedCard(final String cardName, final String setCode, final int count) {
String ttext = setCode == null || setCode.equals("") ? cardName :
String ttext = setCode == null || setCode.isEmpty() ? cardName :
String.format("%s [%s]", cardName, setCode);
return new Token(TokenType.UNSUPPORTED_CARD, count, ttext);
}
@@ -846,7 +846,7 @@ public class DeckRecognizer {
}
if (isCardRarity(text)){
String tokenText = cardRarityTokenMatch(text);
if (tokenText != null && !tokenText.trim().equals(""))
if (tokenText != null && !tokenText.trim().isEmpty())
return new Token(TokenType.CARD_RARITY, tokenText);
return null;
}

View File

@@ -251,7 +251,7 @@ public class CardTranslation {
public static void buildOracleMapping(String faceName, String oracleText) {
if (!needsTranslation() || oracleMappings.containsKey(faceName)) return;
String translatedText = getTranslatedOracle(faceName);
if (translatedText.equals("")) {
if (translatedText.isEmpty()) {
// english card only, fall back
return;
}

View File

@@ -2470,7 +2470,7 @@ public class GameAction {
Localizer.getInstance().getMessage("lblMilledToZone", destination.getTranslatedName()) + ")";
if (showRevealDialog) {
final String message = Localizer.getInstance().getMessage("lblMilledCards");
final boolean addSuffix = !toZoneStr.equals("");
final boolean addSuffix = !toZoneStr.isEmpty();
game.getAction().reveal(milledPlayer, destination, p, false, message, addSuffix);
}
game.getGameLog().add(GameLogEntryType.ZONE_CHANGE, p + " milled " +

View File

@@ -485,7 +485,7 @@ public class AbilityUtils {
} else if (calcX[0].startsWith("PlayerCount")) {
final String hType = calcX[0].substring(11);
final FCollection<Player> players = new FCollection<>();
if (hType.equals("Players") || hType.equals("")) {
if (hType.equals("Players") || hType.isEmpty()) {
players.addAll(game.getPlayers());
val = playerXCount(players, calcX[1], card, ability);
} else if (hType.equals("YourTeam")) {

View File

@@ -430,7 +430,7 @@ public abstract class SpellAbilityEffect {
String trigStr = "Mode$ Phase | Phase$ End of Turn | TriggerZones$ Battlefield " +
"| TriggerDescription$ At the beginning of" + whose + "end step, " + location.toLowerCase()
+ " CARDNAME.";
if (!player.equals("")) {
if (!player.isEmpty()) {
trigStr += " | Player$ " + player;
}

View File

@@ -1078,7 +1078,7 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
searchedLibrary = false;
}
if (!defined && !changeType.equals("") && !changeType.startsWith("EACH")) {
if (!defined && !changeType.isEmpty() && !changeType.startsWith("EACH")) {
fetchList = (CardCollection)AbilityUtils.filterListByType(fetchList, sa.getParam("ChangeType"), sa);
}
fetchList.sort();
@@ -1481,7 +1481,7 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
}
}
if (((!ZoneType.Battlefield.equals(destination) && !changeType.equals("") && !defined && !changeType.equals("Card"))
if (((!ZoneType.Battlefield.equals(destination) && !changeType.isEmpty() && !defined && !changeType.equals("Card"))
|| (sa.hasParam("Reveal") && !movedCards.isEmpty())) && !sa.hasParam("NoReveal")) {
game.getAction().reveal(movedCards, player);
}

View File

@@ -245,7 +245,7 @@ public class ChooseCardEffect extends SpellAbilityEffect {
} else if (value.equals("ChosenType")) {
tag = host.getChosenType();
}
if (!tag.equals("")) {
if (!tag.isEmpty()) {
title = title + " (" + tag +")";
}
}

View File

@@ -690,7 +690,7 @@ public class CountersPutEffect extends SpellAbilityEffect {
protected CounterType chooseTypeFromList(SpellAbility sa, String list, GameEntity obj, PlayerController pc) {
List<CounterType> choices = Lists.newArrayList();
for (String s : list.split(",")) {
if (!s.equals("") && (!sa.hasParam("UniqueType") || obj.getCounters(CounterType.getType(s)) == 0)) {
if (!s.isEmpty() && (!sa.hasParam("UniqueType") || obj.getCounters(CounterType.getType(s)) == 0)) {
CounterType type = CounterType.getType(s);
if (!choices.contains(type)) {
choices.add(type);

View File

@@ -149,7 +149,7 @@ public class MakeCardEffect extends SpellAbilityEffect {
for (final String name : names) {
int toMake = amount;
if (!name.equals("")) {
if (!name.isEmpty()) {
while (toMake > 0) {
PaperCard pc;
if (pack != null) {

View File

@@ -41,7 +41,7 @@ public class PeekAndRevealEffect extends SpellAbilityEffect {
final StringBuilder sb = new StringBuilder();
sb.append(who.equals("") ? peeker : who);
sb.append(who.isEmpty() ? peeker : who);
sb.append(verb).append("the top ");
sb.append(numPeek > 1 ? Lang.getNumeral(numPeek) + " cards " : "card ").append("of ").append(whose);
sb.append(" library.");

View File

@@ -82,7 +82,7 @@ public class ProtectAllEffect extends SpellAbilityEffect {
// Deal with permanents
final String valid = sa.getParamOrDefault("ValidCards", "");
if (!valid.equals("")) {
if (!valid.isEmpty()) {
CardCollectionView list = CardLists.getValidCards(game.getCardsIn(ZoneType.Battlefield), valid, sa.getActivatingPlayer(), host, sa);
for (final Card tgtC : list) {
@@ -107,7 +107,7 @@ public class ProtectAllEffect extends SpellAbilityEffect {
// Deal with Players
final String players = sa.getParamOrDefault("ValidPlayers", "");
if (!players.equals("")) {
if (!players.isEmpty()) {
for (final Player player : AbilityUtils.getDefinedPlayers(host, players, sa)) {
player.addChangedKeywords(gainsKWList, ImmutableList.of(), timestamp, 0);

View File

@@ -2809,7 +2809,7 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
for (final StaticAbility stAb : state.getStaticAbilities()) {
if (!stAb.isSecondary() && !stAb.isClassAbility()) {
final String stAbD = stAb.toString();
if (!stAbD.equals("")) {
if (!stAbD.isEmpty()) {
boolean disabled = getGame() != null && getController() != null && game.getAge() != GameStage.Play && !stAb.checkConditions();
if (disabled) sb.append(grayTag);
sb.append(stAbD);
@@ -3187,7 +3187,7 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
for (final StaticAbility stAb : state.getStaticAbilities()) {
if (!stAb.isSecondary()) {
final String stAbD = stAb.toString();
if (!stAbD.equals("")) {
if (!stAbD.isEmpty()) {
sb.append(stAbD).append("\r\n");
}
}

View File

@@ -683,7 +683,7 @@ public class CardFactoryUtil {
}
String repeffstr = "Event$ Moved | ValidCard$ Card.Self | Destination$ Battlefield "
+ "| Secondary$ True | ReplacementResult$ Updated | Description$ " + desc + (!extraparams.equals("") ? " | " + extraparams : "");
+ "| Secondary$ True | ReplacementResult$ Updated | Description$ " + desc + (!extraparams.isEmpty() ? " | " + extraparams : "");
ReplacementEffect re = ReplacementHandler.parseReplacement(repeffstr, card.getCard(), intrinsic, card);

View File

@@ -254,8 +254,8 @@ public class Cost implements Serializable {
}
}
if (parsedMana == null && (manaParts.length() > 0 || !xMin.equals(""))) {
parsedMana = new CostPartMana(new ManaCost(new ManaCostParser(manaParts.toString())), xMin.equals("") ? null : xMin);
if (parsedMana == null && (manaParts.length() > 0 || !xMin.isEmpty())) {
parsedMana = new CostPartMana(new ManaCost(new ManaCostParser(manaParts.toString())), xMin.isEmpty() ? null : xMin);
}
if (parsedMana != null) {
costParts.add(parsedMana);

View File

@@ -782,7 +782,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
// Thus, to protect the original's set from changes, we make a copy right here.
optionalCosts = EnumSet.copyOf(optionalCosts);
optionalCosts.add(cost);
if (!cost.getPip().equals("")) {
if (!cost.getPip().isEmpty()) {
pipsToReduce.add(cost.getPip());
}
}

View File

@@ -84,15 +84,15 @@ public class StackItemView extends TrackableObject implements IHasCardView {
if (kicked && !generic)
OptionalCostString += "Kicked";
if (entwined)
OptionalCostString += OptionalCostString.equals("") ? "Entwined" : ", Entwined";
OptionalCostString += OptionalCostString.isEmpty() ? "Entwined" : ", Entwined";
if (buyback)
OptionalCostString += OptionalCostString.equals("") ? "Buyback" : ", Buyback";
OptionalCostString += OptionalCostString.isEmpty() ? "Buyback" : ", Buyback";
if (retraced)
OptionalCostString += OptionalCostString.equals("") ? "Retraced" : ", Retraced";
OptionalCostString += OptionalCostString.isEmpty() ? "Retraced" : ", Retraced";
if (jumpstart)
OptionalCostString += OptionalCostString.equals("") ? "Jumpstart" : ", Jumpstart";
OptionalCostString += OptionalCostString.isEmpty() ? "Jumpstart" : ", Jumpstart";
if (additional || generic)
OptionalCostString += OptionalCostString.equals("") ? "Additional" : ", Additional";
OptionalCostString += OptionalCostString.isEmpty() ? "Additional" : ", Additional";
}
set(TrackableProperty.OptionalCosts, OptionalCostString);
}

View File

@@ -202,7 +202,7 @@ public abstract class Trigger extends TriggerReplacementBase {
}
}
}
if (saDesc.equals("")) { // in case we haven't found anything better
if (saDesc.isEmpty()) { // in case we haven't found anything better
saDesc = sa.toString();
}
// string might have leading whitespace

View File

@@ -185,14 +185,14 @@ public class ImageCache {
}
if (altState)
imageKey = imageKey.substring(0, imageKey.length() - ImageKeys.BACKFACE_POSTFIX.length());
if (!specColor.equals(""))
if (!specColor.isEmpty())
imageKey = imageKey.substring(0, imageKey.length() - ImageKeys.SPECFACE_W.length());
if (imageKey.startsWith(ImageKeys.CARD_PREFIX)) {
ipc = ImageUtil.getPaperCardFromImageKey(imageKey);
if (ipc != null) {
if (altState) {
imageKey = ipc.getCardAltImageKey();
} else if (!specColor.equals("")) {
} else if (!specColor.isEmpty()) {
switch (specColor) {
case "white":
imageKey = ipc.getCardWSpecImageKey();

View File

@@ -518,7 +518,7 @@ public class DeckImport<TModel extends DeckBase> extends FDialog {
// we set it to the current one (if any) or set a new one.
// In this way, if this deck will replace the current one, the name will be kept the same!
if (!deck.hasName()){
if (currentDeckName.equals(""))
if (currentDeckName.isEmpty())
deck.setName(Localizer.getInstance().getMessage("lblNewDeckName"));
else
deck.setName(currentDeckName);

View File

@@ -102,7 +102,7 @@ public class DeckController<T extends DeckBase> {
newModel();
isStored = false;
} else
isStored = !this.modelPath.equals("");
isStored = !this.modelPath.isEmpty();
} else {
CardPool catalogClone = new CardPool(view.getInitialCatalog());
deck = pickFromCatalog(deck, catalogClone);

View File

@@ -94,7 +94,7 @@ public final class FImageUtil {
PaperCard card = ImageUtil.getPaperCardFromImageKey(key);
if (altState) {
imageKey = card.getCardAltImageKey();
} else if (!specColor.equals("")) {
} else if (!specColor.isEmpty()) {
switch (specColor) {
case "white":
imageKey = card.getCardWSpecImageKey();
@@ -119,7 +119,7 @@ public final class FImageUtil {
if(altState) {
imageKey = imageKey.substring(0, imageKey.length() - ImageKeys.BACKFACE_POSTFIX.length());
imageKey += "full.jpg";
} else if (!specColor.equals("")) {
} else if (!specColor.isEmpty()) {
imageKey = imageKey.substring(0, imageKey.length() - ImageKeys.SPECFACE_W.length());
imageKey += "full.jpg";
}

View File

@@ -861,7 +861,7 @@ public class AdventurePlayer implements Serializable, SaveFileContent {
}
public void removeItem(String name) {
if (name == null || name.equals("")) return;
if (name == null || name.isEmpty()) return;
inventoryItems.removeValue(name, false);
if (equippedItems.values().contains(name) && !inventoryItems.contains(name, false)) {
equippedItems.values().remove(name);

View File

@@ -73,7 +73,7 @@ public class InventoryScene extends UIScene {
}
}
String item = Current.player().itemInSlot(slotName);
if (item != null && !item.equals("")) {
if (item != null && !item.isEmpty()) {
Button changeButton = null;
for (Button invButton : inventoryButtons) {
if (itemLocation.get(invButton) != null && itemLocation.get(invButton).equals(item)) {
@@ -246,7 +246,7 @@ public class InventoryScene extends UIScene {
if (Current.player().getShards() < data.shardsNeeded)
useButton.setDisabled(true);
if (data.equipmentSlot == null || data.equipmentSlot.equals("")) {
if (data.equipmentSlot == null || data.equipmentSlot.isEmpty()) {
equipButton.setDisabled(true);
} else {
equipButton.setDisabled(false);
@@ -380,7 +380,7 @@ public class InventoryScene extends UIScene {
if (slot.getValue().getChildren().size >= 2)
slot.getValue().removeActorAt(1, false);
String equippedItem = Current.player().itemInSlot(slot.getKey());
if (equippedItem == null || equippedItem.equals(""))
if (equippedItem == null || equippedItem.isEmpty())
continue;
ItemData item = ItemData.getItem(equippedItem);
if (item != null) {

View File

@@ -295,7 +295,7 @@ public class GameHUD extends Stage {
updatelife = true;
}
} else {
if (!lifepointsTextColor.equals("")) {
if (!lifepointsTextColor.isEmpty()) {
lifepointsTextColor = "";
updatelife = true;
}

View File

@@ -701,7 +701,7 @@ public class MapStage extends GameStage {
filteredPossibleShops = possibleShops;
}
Array<ShopData> shops;
if (filteredPossibleShops.size == 0 || shopList.equals(""))
if (filteredPossibleShops.size == 0 || shopList.isEmpty())
shops = WorldData.getShopList();
else {
shops = new Array<>();

View File

@@ -1184,7 +1184,7 @@ public class MatchScreen extends FScreen {
private boolean hasActivePlane() {
if (MatchController.instance.getGameView() != null)
if (MatchController.instance.getGameView().getPlanarPlayer() != null) {
return !MatchController.instance.getGameView().getPlanarPlayer().getCurrentPlaneName().equals("");
return !MatchController.instance.getGameView().getPlanarPlayer().getCurrentPlaneName().isEmpty();
}
return false;
}

View File

@@ -380,7 +380,7 @@ public class VStack extends FDropDown {
int index = text.indexOf(name);
String newtext = "";
String cId = "(" + sourceCard.getId() + ")";
String optionalCostString = !stackInstance.getOptionalCostString().equals("") ? " ("+ stackInstance.getOptionalCostString() + ")" : "";
String optionalCostString = !stackInstance.getOptionalCostString().isEmpty() ? " ("+ stackInstance.getOptionalCostString() + ")" : "";
if (index == -1) {
newtext = TextUtil.fastReplace(text.trim(), " ", " ");

View File

@@ -60,7 +60,7 @@ public class SettingsPage extends TabPage<SettingsScreen> {
public void valueChanged(String newValue) {
// if the new locale needs to use CJK font, disallow change if UI_CJK_FONT is not set yet
ForgePreferences prefs = FModel.getPreferences();
if (prefs.getPref(FPref.UI_CJK_FONT).equals("") &&
if (prefs.getPref(FPref.UI_CJK_FONT).isEmpty() &&
(newValue.equals("zh-CN") || newValue.equals("ja-JP"))) {
String message = "Please download CJK font (from \"Files\"), and set it before change language.";
if (newValue.equals("zh-CN")) {