From b3dc0f5eca1f823274fc78429143460cc174faaa Mon Sep 17 00:00:00 2001 From: "vyacheslav.raskulin" Date: Wed, 9 Sep 2020 15:06:49 +0300 Subject: [PATCH] excessive lambda usage --- .../java/mage/client/chat/LocalCommands.java | 2 +- .../mage/client/dialog/NewTableDialog.java | 2 +- .../client/dialog/NewTournamentDialog.java | 2 +- .../mage/client/dialog/PickChoiceDialog.java | 2 +- .../plugins/adapters/MageActionCallback.java | 4 +- .../client/remote/CallbackClientImpl.java | 4 +- .../java/mage/client/table/TablesPanel.java | 6 +-- .../org/mage/plugins/card/dl/DownloadJob.java | 1 - .../java/mage/client/util/ChrismasTest.java | 38 ++++++++++--------- 9 files changed, 31 insertions(+), 30 deletions(-) diff --git a/Mage.Client/src/main/java/mage/client/chat/LocalCommands.java b/Mage.Client/src/main/java/mage/client/chat/LocalCommands.java index 6b8307d442..2b71177f10 100644 --- a/Mage.Client/src/main/java/mage/client/chat/LocalCommands.java +++ b/Mage.Client/src/main/java/mage/client/chat/LocalCommands.java @@ -37,7 +37,7 @@ public final class LocalCommands { return false; } - final String serverAddress = SessionHandler.getSession().getServerHostname().orElseGet(() -> ""); + final String serverAddress = SessionHandler.getSession().getServerHostname().orElse(""); Optional response = Optional.empty(); String command = st.nextToken(); diff --git a/Mage.Client/src/main/java/mage/client/dialog/NewTableDialog.java b/Mage.Client/src/main/java/mage/client/dialog/NewTableDialog.java index ca03239699..ed875b1a06 100644 --- a/Mage.Client/src/main/java/mage/client/dialog/NewTableDialog.java +++ b/Mage.Client/src/main/java/mage/client/dialog/NewTableDialog.java @@ -614,7 +614,7 @@ public class NewTableDialog extends MageDialog { options.setMinimumRating((Integer) this.spnMinimumRating.getValue()); options.setEdhPowerLevel((Integer) this.spnEdhPowerLevel.getValue()); options.setMullgianType((MulliganType) this.cbMulligan.getSelectedItem()); - String serverAddress = SessionHandler.getSession().getServerHostname().orElseGet(() -> ""); + String serverAddress = SessionHandler.getSession().getServerHostname().orElse(""); options.setBannedUsers(IgnoreList.getIgnoredUsers(serverAddress)); return options; diff --git a/Mage.Client/src/main/java/mage/client/dialog/NewTournamentDialog.java b/Mage.Client/src/main/java/mage/client/dialog/NewTournamentDialog.java index 496a8a3051..c9d96160b4 100644 --- a/Mage.Client/src/main/java/mage/client/dialog/NewTournamentDialog.java +++ b/Mage.Client/src/main/java/mage/client/dialog/NewTournamentDialog.java @@ -1256,7 +1256,7 @@ public class NewTournamentDialog extends MageDialog { tOptions.getMatchOptions().setLimited(false); } - String serverAddress = SessionHandler.getSession().getServerHostname().orElseGet(() -> ""); + String serverAddress = SessionHandler.getSession().getServerHostname().orElse(""); tOptions.getMatchOptions().setBannedUsers(IgnoreList.getIgnoredUsers(serverAddress)); tOptions.getMatchOptions().setMatchTimeLimit((MatchTimeLimit) this.cbTimeLimit.getSelectedItem()); diff --git a/Mage.Client/src/main/java/mage/client/dialog/PickChoiceDialog.java b/Mage.Client/src/main/java/mage/client/dialog/PickChoiceDialog.java index 8ea8bdc0db..ddf82d60f3 100644 --- a/Mage.Client/src/main/java/mage/client/dialog/PickChoiceDialog.java +++ b/Mage.Client/src/main/java/mage/client/dialog/PickChoiceDialog.java @@ -396,7 +396,7 @@ public class PickChoiceDialog extends MageDialog { .addContainerGap()) ); - panelCommandsLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {btCancel, btOK}); + panelCommandsLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, btCancel, btOK); panelCommandsLayout.setVerticalGroup( panelCommandsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) diff --git a/Mage.Client/src/main/java/mage/client/plugins/adapters/MageActionCallback.java b/Mage.Client/src/main/java/mage/client/plugins/adapters/MageActionCallback.java index 7c56a8a74e..51f87c4c8e 100644 --- a/Mage.Client/src/main/java/mage/client/plugins/adapters/MageActionCallback.java +++ b/Mage.Client/src/main/java/mage/client/plugins/adapters/MageActionCallback.java @@ -242,7 +242,7 @@ public class MageActionCallback implements ActionCallback { if (this.startedDragging && prevCardPanel != null && card != null) { for (Component component : card.getCardArea().getComponents()) { if (component instanceof CardPanel) { - if (cardPanels.contains((CardPanel) component)) { + if (cardPanels.contains(component)) { component.setLocation(component.getLocation().x, component.getLocation().y - GO_DOWN_ON_DRAG_Y_OFFSET); } } @@ -316,7 +316,7 @@ public class MageActionCallback implements ActionCallback { for (Component component : container.getComponents()) { if (component instanceof CardPanel) { if (!component.equals(card)) { - if (!cardPanels.contains((CardPanel) component)) { + if (!cardPanels.contains(component)) { component.setLocation(component.getLocation().x, component.getLocation().y + GO_DOWN_ON_DRAG_Y_OFFSET); } cardPanels.add((CardPanel) component); diff --git a/Mage.Client/src/main/java/mage/client/remote/CallbackClientImpl.java b/Mage.Client/src/main/java/mage/client/remote/CallbackClientImpl.java index ae6e378bb5..3cdf9fb93e 100644 --- a/Mage.Client/src/main/java/mage/client/remote/CallbackClientImpl.java +++ b/Mage.Client/src/main/java/mage/client/remote/CallbackClientImpl.java @@ -78,7 +78,7 @@ public class CallbackClientImpl implements CallbackClient { ChatMessage message = (ChatMessage) callback.getData(); // Drop messages from ignored users if (message.getUsername() != null && IgnoreList.IGNORED_MESSAGE_TYPES.contains(message.getMessageType())) { - final String serverAddress = SessionHandler.getSession().getServerHostname().orElseGet(() -> ""); + final String serverAddress = SessionHandler.getSession().getServerHostname().orElse(""); if (IgnoreList.userIsIgnored(serverAddress, message.getUsername())) { break; } @@ -451,7 +451,7 @@ public class CallbackClientImpl implements CallbackClient { null, null, MessageType.USER_INFO, ChatMessage.MessageColor.BLUE); break; case TABLES: - String serverAddress = SessionHandler.getSession().getServerHostname().orElseGet(() -> ""); + String serverAddress = SessionHandler.getSession().getServerHostname().orElse(""); usedPanel.receiveMessage("", new StringBuilder("Download card images by using the \"Images\" main menu.") .append("
Download icons and symbols by using the \"Symbols\" main menu.") .append("
\\list - show a list of available chat commands.") diff --git a/Mage.Client/src/main/java/mage/client/table/TablesPanel.java b/Mage.Client/src/main/java/mage/client/table/TablesPanel.java index 087457e250..b3902afefa 100644 --- a/Mage.Client/src/main/java/mage/client/table/TablesPanel.java +++ b/Mage.Client/src/main/java/mage/client/table/TablesPanel.java @@ -317,7 +317,7 @@ public class TablesPanel extends javax.swing.JPanel { // special sort for created and seat column if (column == TablesTableModel.COLUMN_CREATED || column == TablesTableModel.COLUMN_SEATS) { List sortKeys = getSortKeys(); - if (!sortKeys.isEmpty() && sortKeys.size() == 2) { + if (sortKeys.size() == 2) { // clear sort on second click setSortKeys(null); } else { @@ -936,7 +936,7 @@ public class TablesPanel extends javax.swing.JPanel { // Hide games of ignored players java.util.List> ignoreListFilterList = new ArrayList<>(); - String serverAddress = SessionHandler.getSession().getServerHostname().orElseGet(() -> ""); + String serverAddress = SessionHandler.getSession().getServerHostname().orElse(""); final Set ignoreListCopy = IgnoreList.getIgnoredUsers(serverAddress); if (!ignoreListCopy.isEmpty()) { ignoreListFilterList.add(new RowFilter() { @@ -1707,7 +1707,7 @@ public class TablesPanel extends javax.swing.JPanel { options.setRollbackTurnsAllowed(true); options.setQuitRatio(100); options.setMinimumRating(0); - String serverAddress = SessionHandler.getSession().getServerHostname().orElseGet(() -> ""); + String serverAddress = SessionHandler.getSession().getServerHostname().orElse(""); options.setBannedUsers(IgnoreList.getIgnoredUsers(serverAddress)); table = SessionHandler.createTable(roomId, options); diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/DownloadJob.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/DownloadJob.java index 72c99422ab..b347011e1b 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/DownloadJob.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/DownloadJob.java @@ -112,7 +112,6 @@ public class DownloadJob extends AbstractLaternaBean { * Prepare code to override in custom download tasks (it's calls before work start) */ public void onPreparing() throws Exception { - return; } /** diff --git a/Mage.Client/src/test/java/mage/client/util/ChrismasTest.java b/Mage.Client/src/test/java/mage/client/util/ChrismasTest.java index cbd40cc1ac..3675f95036 100644 --- a/Mage.Client/src/test/java/mage/client/util/ChrismasTest.java +++ b/Mage.Client/src/test/java/mage/client/util/ChrismasTest.java @@ -8,6 +8,8 @@ import java.util.Date; import java.util.GregorianCalendar; import static mage.client.MageFrame.isChrismasTime; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; public class ChrismasTest { @@ -20,24 +22,24 @@ public class ChrismasTest { @Test public void testChrismasDays() throws Exception { // chrismas from 15 december to 15 january - Assert.assertEquals(false, isChrismasTime(getDate(2017, 11, 1))); - Assert.assertEquals(false, isChrismasTime(getDate(2017, 11, 15))); - Assert.assertEquals(false, isChrismasTime(getDate(2017, 11, 30))); - Assert.assertEquals(false, isChrismasTime(getDate(2017, 12, 1))); - Assert.assertEquals(false, isChrismasTime(getDate(2017, 12, 14))); - Assert.assertEquals(true, isChrismasTime(getDate(2017, 12, 15))); - Assert.assertEquals(true, isChrismasTime(getDate(2017, 12, 16))); - Assert.assertEquals(true, isChrismasTime(getDate(2017, 12, 31))); - Assert.assertEquals(true, isChrismasTime(getDate(2018, 1, 1))); - Assert.assertEquals(true, isChrismasTime(getDate(2018, 1, 14))); - Assert.assertEquals(true, isChrismasTime(getDate(2018, 1, 15))); - Assert.assertEquals(false, isChrismasTime(getDate(2018, 1, 16))); - Assert.assertEquals(false, isChrismasTime(getDate(2018, 1, 31))); - Assert.assertEquals(false, isChrismasTime(getDate(2018, 2, 1))); - Assert.assertEquals(false, isChrismasTime(getDate(2018, 12, 1))); - Assert.assertEquals(true, isChrismasTime(getDate(2018, 12, 20))); - Assert.assertEquals(true, isChrismasTime(getDate(2019, 1, 10))); - Assert.assertEquals(false, isChrismasTime(getDate(2019, 1, 25))); + assertFalse(isChrismasTime(getDate(2017, 11, 1))); + assertFalse(isChrismasTime(getDate(2017, 11, 15))); + assertFalse(isChrismasTime(getDate(2017, 11, 30))); + assertFalse(isChrismasTime(getDate(2017, 12, 1))); + assertFalse(isChrismasTime(getDate(2017, 12, 14))); + assertTrue(isChrismasTime(getDate(2017, 12, 15))); + assertTrue(isChrismasTime(getDate(2017, 12, 16))); + assertTrue(isChrismasTime(getDate(2017, 12, 31))); + assertTrue(isChrismasTime(getDate(2018, 1, 1))); + assertTrue(isChrismasTime(getDate(2018, 1, 14))); + assertTrue(isChrismasTime(getDate(2018, 1, 15))); + assertFalse(isChrismasTime(getDate(2018, 1, 16))); + assertFalse(isChrismasTime(getDate(2018, 1, 31))); + assertFalse(isChrismasTime(getDate(2018, 2, 1))); + assertFalse(isChrismasTime(getDate(2018, 12, 1))); + assertTrue(isChrismasTime(getDate(2018, 12, 20))); + assertTrue(isChrismasTime(getDate(2019, 1, 10))); + assertFalse(isChrismasTime(getDate(2019, 1, 25))); } }