list.size > 0 changed to !list.isEmpty

We care about if it's empty or not, not about it's size
This commit is contained in:
vraskulin 2017-01-27 16:04:56 +03:00
parent f60ebfbb1f
commit 0557b5e89c
366 changed files with 532 additions and 548 deletions

View file

@ -181,7 +181,7 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
gImage.setColor(Color.BLACK);
gImage.drawImage(background, 0, 0, this);
if (card.getManaCost().size() > 0) {
if (!card.getManaCost().isEmpty()) {
ImageHelper.drawCosts(card.getManaCost(), gImage, FRAME_MAX_WIDTH - SYMBOL_MAX_XOFFSET, SYMBOL_MAX_YOFFSET, this);
}
@ -197,7 +197,7 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
gImage.drawString(card.getLoyalty(), POWBOX_TEXT_MAX_LEFT, POWBOX_TEXT_MAX_TOP);
}
if (card.getCardTypes().size() > 0) {
if (!card.getCardTypes().isEmpty()) {
gImage.drawString(cardType, CONTENT_MAX_XOFFSET, TYPE_MAX_YOFFSET);
}
@ -211,7 +211,7 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
gSmall.drawString(card.getLoyalty(), Config.dimensions.powBoxTextLeft, Config.dimensions.powBoxTextTop);
}
if (card.getCardTypes().size() > 0) {
if (!card.getCardTypes().isEmpty()) {
gSmall.drawString(cardType, Config.dimensions.contentXOffset, Config.dimensions.typeYOffset);
}
drawText();
@ -232,7 +232,7 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
}
} else {
sb.append(card.getName());
if (card.getManaCost().size() > 0) {
if (!card.getManaCost().isEmpty()) {
sb.append('\n').append(card.getManaCost());
}
sb.append('\n').append(cardType);
@ -247,7 +247,7 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
for (String rule : getRules()) {
sb.append('\n').append(rule);
}
if (card.getExpansionSetCode() != null && card.getExpansionSetCode().length() > 0) {
if (card.getExpansionSetCode() != null && !card.getExpansionSetCode().isEmpty()) {
sb.append('\n').append(card.getCardNumber()).append(" - ");
sb.append(Sets.getInstance().get(card.getExpansionSetCode()).getName()).append(" - ");
sb.append(card.getRarity().toString());
@ -308,7 +308,7 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
sbType.append(cardType.toString()).append(' ');
}
if (card.getSubTypes().size() > 0) {
if (!card.getSubTypes().isEmpty()) {
sbType.append("- ");
for (String subType : card.getSubTypes()) {
sbType.append(subType).append(' ');

View file

@ -163,7 +163,7 @@ public class CardArea extends JPanel implements MouseListener {
private void loadCardsMany(CardsView showCards, BigCard bigCard, UUID gameId) {
int rowsOfCards = 20;
int columns = 1;
if (showCards != null && showCards.size() > 0) {
if (showCards != null && !showCards.isEmpty()) {
Rectangle rectangle = new Rectangle(cardDimension.width, cardDimension.height);
int count = 0;
for (CardView card : showCards.values()) {

View file

@ -225,7 +225,7 @@ public class Cards extends javax.swing.JPanel {
}
if (!isVisibleIfEmpty) {
cardArea.setVisible(cards.size() > 0);
cardArea.setVisible(!cards.isEmpty());
}
sizeCards(getCardDimension());

View file

@ -322,7 +322,7 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
cardArea.remove(card);
}
if (cards != null && cards.size() > 0) {
if (cards != null && !cards.isEmpty()) {
Rectangle rectangle = new Rectangle(cardDimension.width, cardDimension.height);
List<CardView> sortedCards = new ArrayList<>(cards.values());
switch (sortSetting.getSortBy()) {

View file

@ -1077,7 +1077,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
for (Sort s : sortMenuItems.keySet()) {
sortMenuItems.get(s).setSelected(cardSort == s);
}
hideSelected.setEnabled(dragCardList().size() > 0);
hideSelected.setEnabled(!dragCardList().isEmpty());
separateButton.setSelected(separateCreatures);
menu.show(e.getComponent(), e.getX(), e.getY());
}
@ -1534,7 +1534,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
List<CardInfo> cardPool = CardRepository.instance.findCards(cardCriteria);
if (cardPool.size() > 0) {
if (!cardPool.isEmpty()) {
Card acard = cardPool.get(RandomUtil.nextInt(cardPool.size())).getMockCard();
if (acard.getName().equals(card.getName())) {
@ -1656,7 +1656,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
if (trackedCards.containsKey(info.getSetCode()) && trackedCards.get(info.getSetCode()).containsKey(info.getCardNum())) {
ArrayList<CardView> candidates
= trackedCards.get(info.getSetCode()).get(info.getCardNum());
if (candidates.size() > 0) {
if (!candidates.isEmpty()) {
gridStack.add(candidates.remove(0));
thisMaxStackSize = Math.max(thisMaxStackSize, gridStack.size());
}

View file

@ -106,7 +106,7 @@ public class Permanent extends Card {
if (permanent.getOriginal() != null) {
sb.append("\n----- Originally -------\n");
sb.append(permanent.getOriginal().getName());
if (permanent.getOriginal().getManaCost().size() > 0) {
if (!permanent.getOriginal().getManaCost().isEmpty()) {
sb.append('\n').append(permanent.getOriginal().getManaCost());
}
sb.append('\n').append(getType(permanent.getOriginal()));
@ -122,7 +122,7 @@ public class Permanent extends Card {
for (String rule: getRules()) {
sb.append('\n').append(rule);
}
if (permanent.getOriginal().getExpansionSetCode().length() > 0) {
if (!permanent.getOriginal().getExpansionSetCode().isEmpty()) {
sb.append('\n').append(permanent.getCardNumber()).append(" - ");
sb.append('\n').append(Sets.getInstance().get(permanent.getOriginal().getExpansionSetCode()).getName()).append(" - ");
sb.append(permanent.getOriginal().getRarity().toString());

View file

@ -51,7 +51,7 @@ public class MageTextArea extends JEditorPane {
text = text.replace("\r\n", "<div style='font-size:5pt'></div>");
final String basicText = ManaSymbols.replaceSymbolsWithHTML(text, ManaSymbols.Type.DIALOG);
if (text.length() > 0) {
if (!text.isEmpty()) {
buffer.append(basicText);
}

View file

@ -296,7 +296,7 @@ public class AbilityPicker extends JXPanel implements MouseWheelListener {
text = text.replace("\r\n", "<div style='font-size:5pt'></div>");
//text += "<br>";
if (text.length() > 0) {
if (!text.isEmpty()) {
buffer.append(ManaSymbols.replaceSymbolsWithHTML(text, ManaSymbols.Type.DIALOG));
}

View file

@ -62,7 +62,7 @@ public class CardHelper {
type.append(cardType.toString());
type.append(' ');
}
if (c.getSubTypes().size() > 0) {
if (!c.getSubTypes().isEmpty()) {
type.append("- ");
for (String subType : c.getSubTypes()) {
type.append(subType);

View file

@ -137,7 +137,7 @@ public class CardInfoWindowDialog extends MageDialog {
String titel = name + " (" + exile.size() + ')';
setTitle(titel);
this.setTitelBarToolTip(titel);
if (exile.size() > 0) {
if (!exile.isEmpty()) {
show();
if (changed) {
try {

View file

@ -507,7 +507,7 @@ public class NewTableDialog extends MageDialog {
while (players.size() != numPlayers) {
TablePlayerPanel playerPanel = new TablePlayerPanel();
String playerType = "Human";
if (prefPlayerTypes.size() >= players.size() && players.size() > 0) {
if (prefPlayerTypes.size() >= players.size() && !players.isEmpty()) {
playerType = prefPlayerTypes.get(players.size() - 1);
}
playerPanel.init(players.size() + 2, playerType);

View file

@ -826,7 +826,7 @@ public class NewTournamentDialog extends MageDialog {
txtRandomPacks.setEnabled(false);
txtRandomPacks.setLineWrap(true);
String randomPrefs = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PACKS_RANDOM_DRAFT, "");
if (randomPrefs.length() > 0) {
if (!randomPrefs.isEmpty()) {
txtRandomPacks.setText(randomPrefs);
ArrayList<String> theList = new ArrayList<>();
theList.addAll(Arrays.asList(randomPrefs.split(";")));
@ -1026,7 +1026,7 @@ public class NewTournamentDialog extends MageDialog {
}
private void loadBoosterPacks(String packString) {
if (packString.length()>0) {
if (!packString.isEmpty()) {
String[] packsArray = packString.substring(1, packString.length() - 1).split(",");
int packNumber = 0;
for (String pack : packsArray ){

View file

@ -723,7 +723,7 @@ public final class GamePanel extends javax.swing.JPanel {
if (!handCards.containsKey(chosenHandKey)) {
chosenHandKey = YOUR_HAND;
}
} else if (chosenHandKey.isEmpty() && handCards.size() > 0) {
} else if (chosenHandKey.isEmpty() && !handCards.isEmpty()) {
chosenHandKey = handCards.keySet().iterator().next();
}
if (chosenHandKey != null && handCards.containsKey(chosenHandKey)) {
@ -854,7 +854,7 @@ public final class GamePanel extends javax.swing.JPanel {
showRevealed(game);
showLookedAt(game);
if (game.getCombat().size() > 0) {
if (!game.getCombat().isEmpty()) {
CombatManager.getInstance().showCombat(game.getCombat(), gameId);
} else {
CombatManager.getInstance().hideCombat(gameId);
@ -1164,7 +1164,7 @@ public final class GamePanel extends javax.swing.JPanel {
updateGame(gameView);
Map<String, Serializable> options0 = options == null ? new HashMap<>() : options;
ShowCardsDialog dialog = null;
if (cardView != null && cardView.size() > 0) {
if (cardView != null && !cardView.isEmpty()) {
dialog = showCards(message, cardView, required, options0, popupMenuType);
options0.put("dialog", dialog);
}
@ -2130,7 +2130,7 @@ public final class GamePanel extends javax.swing.JPanel {
choices,
this.chosenHandKey);
if (newChosenHandKey != null && newChosenHandKey.length() > 0) {
if (newChosenHandKey != null && !newChosenHandKey.isEmpty()) {
this.chosenHandKey = newChosenHandKey;
CardsView cards = handCards.get(chosenHandKey);
handContainer.loadCards(cards, bigCard, gameId);

View file

@ -259,7 +259,7 @@ public class TablesPanel extends javax.swing.JPanel {
switch (action) {
case "Replay":
List<UUID> gameList = matchesModel.getListofGames(modelRow);
if (gameList != null && gameList.size() > 0) {
if (gameList != null && !gameList.isEmpty()) {
if (gameList.size() == 1) {
SessionHandler.replayGame(gameList.get(0));
} else {

View file

@ -86,7 +86,7 @@ public class ImageHelper {
}
public static void drawCosts(List<String> costs, Graphics2D g, int xOffset, int yOffset, ImageObserver o) {
if (costs.size() > 0) {
if (!costs.isEmpty()) {
int costLeft = xOffset;
for (int i = costs.size() - 1; i >= 0; i--) {
String symbol = costs.get(i);

View file

@ -49,7 +49,7 @@ public class MageTableRowSorter extends TableRowSorter<TableModel> {
@Override
public void toggleSortOrder(int column) {
List<? extends SortKey> sortKeys = getSortKeys();
if (sortKeys.size() > 0) {
if (!sortKeys.isEmpty()) {
if (sortKeys.get(0).getSortOrder() == SortOrder.DESCENDING) {
setSortKeys(null);
return;

View file

@ -135,7 +135,7 @@ public class ArrowBuilder {
if (map.containsKey(gameId)) {
Map<Type, List<Arrow>> innerMap = map.get(gameId);
java.util.List<Arrow> arrows = innerMap.get(type);
if (arrows != null && arrows.size() > 0) {
if (arrows != null && !arrows.isEmpty()) {
JPanel p = getArrowsPanel(gameId);
synchronized (map) {
for (Arrow arrow : arrows) {

View file

@ -330,7 +330,7 @@ public class GuiDisplayUtil {
}
}
}
if (textLines.lines.size() > 0) {
if (!textLines.lines.isEmpty()) {
for (String textLine : textLines.lines) {
if (textLine != null && !textLine.replace(".", "").trim().isEmpty()) {
rule.append("<p style='margin: 2px'>").append(textLine).append("</p>");
@ -339,7 +339,7 @@ public class GuiDisplayUtil {
}
String legal = rule.toString();
if (legal.length() > 0) {
if (!legal.isEmpty()) {
legal = legal.replaceAll("\\{this\\}", card.getName().isEmpty() ? "this" : card.getName());
legal = legal.replaceAll("\\{source\\}", card.getName().isEmpty() ? "this" : card.getName());
buffer.append(ManaSymbols.replaceSymbolsWithHTML(legal, ManaSymbols.Type.TOOLTIP));
@ -366,7 +366,7 @@ public class GuiDisplayUtil {
for (CardType cardType : card.getCardTypes()) {
types += cardType.toString() + ' ';
}
if (card.getSubTypes().size() > 0) {
if (!card.getSubTypes().isEmpty()) {
types += "- ";
}
for (String subType : card.getSubTypes()) {

View file

@ -36,7 +36,7 @@ public class UpdateMemUsageTask extends SwingWorker<Void, Float> {
@Override
protected void process(List<Float> chunks) {
if (chunks != null && chunks.size() > 0) {
if (chunks != null && !chunks.isEmpty()) {
Float memUsage = chunks.get(chunks.size() - 1);
if (memUsage != null) {
jLabelToDisplayInfo.setText(Math.round(memUsage) + "% Mem free");

View file

@ -688,7 +688,7 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
sbType.append(cardType.toString()).append(' ');
}
if (card.getSubTypes().size() > 0) {
if (!card.getSubTypes().isEmpty()) {
sbType.append("- ");
for (String subType : card.getSubTypes()) {
sbType.append(subType).append(' ');
@ -706,7 +706,7 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
}
} else {
sb.append(card.getName());
if (card.getManaCost().size() > 0) {
if (!card.getManaCost().isEmpty()) {
sb.append('\n').append(card.getManaCost());
}
sb.append('\n').append(cardType);
@ -724,7 +724,7 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
for (String rule : card.getRules()) {
sb.append('\n').append(rule);
}
if (card.getExpansionSetCode() != null && card.getExpansionSetCode().length() > 0) {
if (card.getExpansionSetCode() != null && !card.getExpansionSetCode().isEmpty()) {
sb.append('\n').append(card.getCardNumber()).append(" - ");
sb.append(card.getExpansionSetCode()).append(" - ");
sb.append(card.getRarity().toString());

View file

@ -385,7 +385,7 @@ public abstract class CardRenderer {
for (CardType cardType : cardView.getCardTypes()) {
sbType.append(cardType.toString()).append(' ');
}
if (cardView.getSubTypes().size() > 0) {
if (!cardView.getSubTypes().isEmpty()) {
sbType.append("- ");
for (String subType : cardView.getSubTypes()) {
sbType.append(subType).append(' ');

View file

@ -87,7 +87,7 @@ public class TextboxRule {
// Do it in reverse order for proper handling of regions where
// there are multiple attributes stacked (EG: bold + italic)
AttributedString attributedRule = new AttributedString(text);
if (text.length() != 0) {
if (!text.isEmpty()) {
attributedRule.addAttribute(TextAttribute.FONT, normal);
for (int i = regions.size() - 1; i >= 0; --i) {
regions.get(i).applyToAttributedString(attributedRule, normal, italic);

View file

@ -179,7 +179,7 @@ public class CardPluginImpl implements CardPlugin {
break;
}
List<CounterView> counters = firstPanel.getOriginalPermanent().getCounters();
if (counters != null && counters.size() > 0) {
if (counters != null && !counters.isEmpty()) {
// don't put to first panel if it has counters
insertIndex = i;
break;
@ -191,7 +191,7 @@ public class CardPluginImpl implements CardPlugin {
continue;
}
counters = permanent.getOriginalPermanent().getCounters();
if (counters != null && counters.size() > 0) {
if (counters != null && !counters.isEmpty()) {
// if a land has counter, put it to the right
insertIndex = i + 1;
continue;