Equals should be compared with == but not equals()

This commit is contained in:
vraskulin 2017-03-22 14:50:46 +03:00
parent 1f9b51d833
commit d93061c0bc
175 changed files with 348 additions and 344 deletions

View file

@ -1046,8 +1046,8 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
// close & remove sideboarding or construction pane if open
if (window instanceof DeckEditorPane) {
DeckEditorPane deckEditorPane = (DeckEditorPane) window;
if (deckEditorPane.getDeckEditorMode().equals(DeckEditorMode.LIMITED_BUILDING)
|| deckEditorPane.getDeckEditorMode().equals(DeckEditorMode.SIDEBOARDING)) {
if (deckEditorPane.getDeckEditorMode() == DeckEditorMode.LIMITED_BUILDING
|| deckEditorPane.getDeckEditorMode() == DeckEditorMode.SIDEBOARDING) {
deckEditorPane.removeFrame();
}
}

View file

@ -111,7 +111,7 @@ public class BigCard extends JComponent {
image = TransformedImageCache.getResizedImage((BufferedImage)image, getWidth(), getHeight());
}
if (this.cardId == null || !enlargeMode.equals(this.enlargeMode) || !this.cardId.equals(cardId)) {
if (this.cardId == null || enlargeMode != this.enlargeMode || !this.cardId.equals(cardId)) {
if (this.panel != null) {
remove(this.panel);
}

View file

@ -192,7 +192,7 @@ public class CardGrid extends javax.swing.JLayeredPane implements MouseListener,
}
break;
case RARITY:
if (!cardImg.getOriginal().getRarity().equals(lastCard.getOriginal().getRarity())) {
if (cardImg.getOriginal().getRarity() != lastCard.getOriginal().getRarity()) {
curColumn++;
curRow = 0;
}

View file

@ -88,10 +88,10 @@ public class ChatPanelSeparated extends ChatPanelBasic {
textColor = MESSAGE_COLOR;
userSeparator = ": ";
}
if (color.equals(ChatMessage.MessageColor.ORANGE)) {
if (color == ChatMessage.MessageColor.ORANGE) {
textColor = "Orange";
}
if (color.equals(ChatMessage.MessageColor.YELLOW)) {
if (color == ChatMessage.MessageColor.YELLOW) {
textColor = "Yellow";
}
if (username != null && !username.isEmpty()) {

View file

@ -39,7 +39,7 @@ public class DialogContainer extends JPanel {
if (dialogType == DialogManager.MTGDialogs.MessageDialog) {
//backgroundColor = new Color(0, 255, 255, 60);
if (params.type.equals(MessageDlg.Types.Warning)) {
if (params.type == MessageDlg.Types.Warning) {
backgroundColor = new Color(255, 0, 0, 90);
} else {
backgroundColor = new Color(0, 0, 0, 90);

View file

@ -162,7 +162,7 @@ public class CardInfoWindowDialog extends MageDialog {
public void loadCards(CardsView showCards, BigCard bigCard, UUID gameId, boolean revertOrder) {
cards.loadCards(showCards, bigCard, gameId, revertOrder);
if (showType.equals(ShowType.GRAVEYARD)) {
if (showType == ShowType.GRAVEYARD) {
int qty = qtyCardTypes(showCards);
String titel = name + "'s Graveyard (" + showCards.size() + ") - " + qty + ((qty == 1) ? " Card Type" : " Card Types");
setTitle(titel);
@ -173,7 +173,7 @@ public class CardInfoWindowDialog extends MageDialog {
@Override
public void show() {
if (showType.equals(ShowType.EXILE)) {
if (showType == ShowType.EXILE) {
if (cards == null || cards.getNumberOfCards() == 0) {
return;
}

View file

@ -2958,7 +2958,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
}
connection.setProxyType(configProxyType);
if (!configProxyType.equals(ProxyType.NONE)) {
if (configProxyType != ProxyType.NONE) {
String host = getCachedValue(KEY_PROXY_ADDRESS, "");
String port = getCachedValue(KEY_PROXY_PORT, "");
if (!host.isEmpty() && !port.isEmpty()) {

View file

@ -1144,7 +1144,7 @@ public final class GamePanel extends javax.swing.JPanel {
PopUpMenuType popupMenuType = null;
if (options != null) {
if (options.containsKey("targetZone")) {
if (Zone.HAND.equals(options.get("targetZone"))) { // mark selectable target cards in hand
if (Zone.HAND == options.get("targetZone")) { // mark selectable target cards in hand
List<UUID> choosen = null;
if (options.containsKey("chosen")) {
choosen = (List<UUID>) options.get("chosen");
@ -1163,7 +1163,7 @@ public final class GamePanel extends javax.swing.JPanel {
}
}
}
if (options.containsKey("queryType") && PlayerQueryEvent.QueryType.PICK_ABILITY.equals(options.get("queryType"))) {
if (options.containsKey("queryType") && PlayerQueryEvent.QueryType.PICK_ABILITY == options.get("queryType")) {
popupMenuType = PopUpMenuType.TRIGGER_ORDER;
}
}
@ -1263,7 +1263,7 @@ public final class GamePanel extends javax.swing.JPanel {
hideAll();
ShowCardsDialog showCards = new ShowCardsDialog();
JPopupMenu popupMenu = null;
if (PopUpMenuType.TRIGGER_ORDER.equals(popupMenuType)) {
if (PopUpMenuType.TRIGGER_ORDER == popupMenuType) {
popupMenu = popupMenuTriggerOrder;
}
showCards.loadCards(title, cards, bigCard, gameId, required, options, popupMenu, getShowCardsEventListener(showCards));

View file

@ -145,7 +145,7 @@ public class CallbackClientImpl implements CallbackClient {
createChatStartMessage(panel);
}
// send the message to subchat if exists and it's not a game message
if (!message.getMessageType().equals(MessageType.GAME) && panel.getConnectedChat() != null) {
if (message.getMessageType() != MessageType.GAME && panel.getConnectedChat() != null) {
panel.getConnectedChat().receiveMessage(message.getUsername(), message.getMessage(), message.getTime(), message.getMessageType(), ChatMessage.MessageColor.BLACK);
} else {
panel.receiveMessage(message.getUsername(), message.getMessage(), message.getTime(), message.getMessageType(), message.getColor());
@ -157,7 +157,7 @@ public class CallbackClientImpl implements CallbackClient {
case "serverMessage":
if (callback.getData() != null) {
ChatMessage message = (ChatMessage) callback.getData();
if (message.getColor().equals(ChatMessage.MessageColor.RED)) {
if (message.getColor() == ChatMessage.MessageColor.RED) {
JOptionPane.showMessageDialog(null, message.getMessage(), "Server message", JOptionPane.WARNING_MESSAGE);
} else {
JOptionPane.showMessageDialog(null, message.getMessage(), "Server message", JOptionPane.INFORMATION_MESSAGE);

View file

@ -147,7 +147,7 @@ public final class GuiDisplayUtil {
for (String rule : card.getRules()) {
textLines.basicTextLength += rule.length();
}
if (card.getMageObjectType().equals(MageObjectType.PERMANENT)) {
if (card.getMageObjectType() == MageObjectType.PERMANENT) {
if (card.getPairedCard() != null) {
textLines.lines.add("<span color='green'><i>Paired with another creature</i></span>");
textLines.basicTextLength += 30;

View file

@ -65,7 +65,7 @@ public class CardPanelRenderImpl extends CardPanel {
if (a.getRarity() == null || b.getRarity() == null) {
return false;
}
if (!a.getRarity().equals(b.getRarity())) {
if (a.getRarity() != b.getRarity()) {
return false;
}
if (a.getCardNumber() != null && !a.getCardNumber().equals(b.getCardNumber())) {

View file

@ -460,7 +460,7 @@ public class CardPluginImpl implements CardPlugin {
continue;
}
// all attached permanents are grouped separately later
if (!type.equals(RowType.attached) && RowType.attached.isType(permanent)) {
if (type != RowType.attached && RowType.attached.isType(permanent)) {
continue;
}
Stack stack = new Stack();

View file

@ -142,7 +142,7 @@ public class MythicspoilerComSource implements CardImageSource {
String urlDocument;
Document doc;
if (proxyType.equals(ProxyType.NONE)) {
if (proxyType == ProxyType.NONE) {
urlDocument = pageUrl;
doc = Jsoup.connect(urlDocument).get();
} else {

View file

@ -332,7 +332,7 @@ public class WizardCardsImageSource implements CardImageSource {
Preferences prefs = MageFrame.getPreferences();
Connection.ProxyType proxyType = Connection.ProxyType.valueByText(prefs.get("proxyType", "None"));
Document doc;
if (proxyType.equals(ProxyType.NONE)) {
if (proxyType == ProxyType.NONE) {
doc = Jsoup.connect(urlString).get();
} else {
String proxyServer = prefs.get("proxyAddress", "");

View file

@ -216,7 +216,7 @@ public final class CardImageUtils {
public static Proxy getProxyFromPreferences() {
Preferences prefs = MageFrame.getPreferences();
Connection.ProxyType proxyType = Connection.ProxyType.valueByText(prefs.get("proxyType", "None"));
if (!proxyType.equals(ProxyType.NONE)) {
if (proxyType != ProxyType.NONE) {
String proxyServer = prefs.get("proxyAddress", "");
int proxyPort = Integer.parseInt(prefs.get("proxyPort", "0"));
return new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyServer, proxyPort));