excessive lambda usage

This commit is contained in:
vyacheslav.raskulin 2020-09-09 15:06:49 +03:00
parent 8b31333d9d
commit b3dc0f5eca
9 changed files with 31 additions and 30 deletions

View file

@ -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<String> response = Optional.empty();
String command = st.nextToken();

View file

@ -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;

View file

@ -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());

View file

@ -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)

View file

@ -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);

View file

@ -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("<br/>Download icons and symbols by using the \"Symbols\" main menu.")
.append("<br/>\\list - show a list of available chat commands.")

View file

@ -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<? extends SortKey> 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<RowFilter<Object, Object>> ignoreListFilterList = new ArrayList<>();
String serverAddress = SessionHandler.getSession().getServerHostname().orElseGet(() -> "");
String serverAddress = SessionHandler.getSession().getServerHostname().orElse("");
final Set<String> ignoreListCopy = IgnoreList.getIgnoredUsers(serverAddress);
if (!ignoreListCopy.isEmpty()) {
ignoreListFilterList.add(new RowFilter<Object, Object>() {
@ -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);

View file

@ -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;
}
/**

View file

@ -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)));
}
}